@@ -206,6 +206,52 @@ void fromException_providerReturnsNull_noProperties() {
206206 assertNull (details .getProperties ());
207207 }
208208
209+ @ Test
210+ void fromException_acceptsErrorAndPreservesType () {
211+ // Errors aren't Exceptions, but activity dispatchers catch Throwable. fromException should
212+ // accept them so the original error type (e.g. StackOverflowError) is reported instead of
213+ // being hidden behind a synthetic RuntimeException wrapper.
214+ StackOverflowError error = new StackOverflowError ("too deep" );
215+
216+ FailureDetails details = FailureDetails .fromException (error , null );
217+
218+ assertEquals ("java.lang.StackOverflowError" , details .getErrorType ());
219+ assertEquals ("too deep" , details .getErrorMessage ());
220+ assertNull (details .getProperties ());
221+ }
222+
223+ @ Test
224+ void fromException_errorWithCause_preservesInnerFailure () {
225+ IOException cause = new IOException ("disk full" );
226+ OutOfMemoryError error = new OutOfMemoryError ("heap exhausted" );
227+ error .initCause (cause );
228+
229+ FailureDetails details = FailureDetails .fromException (error , null );
230+
231+ assertEquals ("java.lang.OutOfMemoryError" , details .getErrorType ());
232+ assertNotNull (details .getInnerFailure ());
233+ assertEquals ("java.io.IOException" , details .getInnerFailure ().getErrorType ());
234+ assertEquals ("disk full" , details .getInnerFailure ().getErrorMessage ());
235+ }
236+
237+ @ Test
238+ void fromException_errorWithProvider_skipsProviderForError () {
239+ // The provider contract takes Exception, not Throwable, so for an Error we shouldn't
240+ // call the provider at all. The Error itself still needs to be reported faithfully.
241+ ExceptionPropertiesProvider provider = exception -> {
242+ Map <String , Object > props = new HashMap <>();
243+ props .put ("called" , true );
244+ return props ;
245+ };
246+
247+ StackOverflowError error = new StackOverflowError ("too deep" );
248+
249+ FailureDetails details = FailureDetails .fromException (error , provider );
250+
251+ assertEquals ("java.lang.StackOverflowError" , details .getErrorType ());
252+ assertNull (details .getProperties ());
253+ }
254+
209255 @ Test
210256 void fromException_providerSelectivelyReturnsProperties () {
211257 ExceptionPropertiesProvider provider = exception -> {
0 commit comments