@@ -254,6 +254,13 @@ defmodule Sentry.Event do
254254 `:message` option is present. This is not present by default. See
255255 `Sentry.capture_message/2`. *Available since v10.1.0*.
256256 """
257+ ] ,
258+
259+ ## Internal options
260+ handled: [
261+ type: :boolean ,
262+ default: true ,
263+ doc: false
257264 ]
258265 ]
259266
@@ -330,6 +337,7 @@ defmodule Sentry.Event do
330337 exception = Keyword . get ( opts , :exception )
331338 stacktrace = Keyword . get ( opts , :stacktrace )
332339 source = Keyword . get ( opts , :event_source )
340+ handled? = Keyword . fetch! ( opts , :handled )
333341
334342 event = % __MODULE__ {
335343 attachments: attachments_context ,
@@ -338,7 +346,7 @@ defmodule Sentry.Event do
338346 culprit: culprit_from_stacktrace ( Keyword . get ( opts , :stacktrace , [ ] ) ) ,
339347 environment: Config . environment_name ( ) ,
340348 event_id: UUID . uuid4_hex ( ) ,
341- exception: List . wrap ( coerce_exception ( exception , stacktrace , message ) ) ,
349+ exception: List . wrap ( coerce_exception ( exception , stacktrace , message , handled? ) ) ,
342350 extra: extra ,
343351 fingerprint: Keyword . fetch! ( opts , :fingerprint ) ,
344352 level: Keyword . fetch! ( opts , :level ) ,
@@ -403,11 +411,13 @@ defmodule Sentry.Event do
403411 # If we have a message with a stacktrace, but no exceptions, for now we store the stacktrace in
404412 # the "threads" interface and we don't fill in the "exception" interface altogether. This might
405413 # be eventually fixed in Sentry itself: https://github.com/getsentry/sentry/issues/61239
406- defp coerce_exception ( _exception = nil , _stacktrace_or_nil , message ) when is_binary ( message ) do
414+ defp coerce_exception ( _exception = nil , _stacktrace_or_nil , message , _handled? )
415+ when is_binary ( message ) do
407416 nil
408417 end
409418
410- defp coerce_exception ( exception , stacktrace_or_nil , _message ) when is_exception ( exception ) do
419+ defp coerce_exception ( exception , stacktrace_or_nil , _message , handled? )
420+ when is_exception ( exception ) do
411421 stacktrace =
412422 if is_list ( stacktrace_or_nil ) do
413423 % Interfaces.Stacktrace { frames: stacktrace_to_frames ( stacktrace_or_nil ) }
@@ -416,11 +426,12 @@ defmodule Sentry.Event do
416426 % Interfaces.Exception {
417427 type: inspect ( exception . __struct__ ) ,
418428 value: Exception . message ( exception ) ,
419- stacktrace: stacktrace
429+ stacktrace: stacktrace ,
430+ mechanism: % Interfaces.Exception.Mechanism { handled: handled? }
420431 }
421432 end
422433
423- defp coerce_exception ( _exception = nil , stacktrace , _message = nil ) do
434+ defp coerce_exception ( _exception = nil , stacktrace , _message = nil , _handled? ) do
424435 unless is_nil ( stacktrace ) do
425436 raise ArgumentError ,
426437 "cannot provide a :stacktrace option without an exception or a message, got: #{ inspect ( stacktrace ) } "
0 commit comments