@@ -418,15 +418,10 @@ defmodule Sentry.Event do
418418
419419 defp coerce_exception ( exception , stacktrace_or_nil , _message , handled? )
420420 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-
426421 % Interfaces.Exception {
427422 type: inspect ( exception . __struct__ ) ,
428423 value: Exception . message ( exception ) ,
429- stacktrace: stacktrace ,
424+ stacktrace: coerce_stacktrace ( stacktrace_or_nil ) ,
430425 mechanism: % Interfaces.Exception.Mechanism { handled: handled? }
431426 }
432427 end
@@ -441,7 +436,7 @@ defmodule Sentry.Event do
441436 defp add_thread_with_stacktrace ( % __MODULE__ { } = event , stacktrace ) when is_list ( stacktrace ) do
442437 thread = % Interfaces.Thread {
443438 id: UUID . uuid4_hex ( ) ,
444- stacktrace: % Interfaces.Stacktrace { frames: stacktrace_to_frames ( stacktrace ) }
439+ stacktrace: coerce_stacktrace ( stacktrace )
445440 }
446441
447442 % __MODULE__ { event | threads: [ thread ] }
@@ -464,6 +459,17 @@ defmodule Sentry.Event do
464459 |> create_event ( )
465460 end
466461
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+
467473 defp stacktrace_to_frames ( stacktrace ) when is_list ( stacktrace ) do
468474 in_app_module_allow_list = Config . in_app_module_allow_list ( )
469475
0 commit comments