@@ -418,15 +418,10 @@ defmodule Sentry.Event do
418
418
419
419
defp coerce_exception ( exception , stacktrace_or_nil , _message , handled? )
420
420
when is_exception ( exception ) do
421
- stacktrace =
422
- if is_list ( stacktrace_or_nil ) do
423
- % Interfaces.Stacktrace { frames: stacktrace_to_frames ( stacktrace_or_nil ) }
424
- end
425
-
426
421
% Interfaces.Exception {
427
422
type: inspect ( exception . __struct__ ) ,
428
423
value: Exception . message ( exception ) ,
429
- stacktrace: stacktrace ,
424
+ stacktrace: coerce_stacktrace ( stacktrace_or_nil ) ,
430
425
mechanism: % Interfaces.Exception.Mechanism { handled: handled? }
431
426
}
432
427
end
@@ -441,7 +436,7 @@ defmodule Sentry.Event do
441
436
defp add_thread_with_stacktrace ( % __MODULE__ { } = event , stacktrace ) when is_list ( stacktrace ) do
442
437
thread = % Interfaces.Thread {
443
438
id: UUID . uuid4_hex ( ) ,
444
- stacktrace: % Interfaces.Stacktrace { frames: stacktrace_to_frames ( stacktrace ) }
439
+ stacktrace: coerce_stacktrace ( stacktrace )
445
440
}
446
441
447
442
% __MODULE__ { event | threads: [ thread ] }
@@ -464,6 +459,17 @@ defmodule Sentry.Event do
464
459
|> create_event ( )
465
460
end
466
461
462
+ defp coerce_stacktrace ( nil ) do
463
+ nil
464
+ end
465
+
466
+ defp coerce_stacktrace ( stacktrace ) when is_list ( stacktrace ) do
467
+ case stacktrace_to_frames ( stacktrace ) do
468
+ [ ] -> nil
469
+ frames -> % Interfaces.Stacktrace { frames: frames }
470
+ end
471
+ end
472
+
467
473
defp stacktrace_to_frames ( stacktrace ) when is_list ( stacktrace ) do
468
474
in_app_module_allow_list = Config . in_app_module_allow_list ( )
469
475
0 commit comments