Skip to content
Merged
Prev Previous commit
Next Next commit
Update
  • Loading branch information
buenaflor committed Jul 8, 2024
commit 705d3d539a30eef170089e41deb01a170d1e9aae
13 changes: 10 additions & 3 deletions dart/lib/src/sentry_envelope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,15 @@ class SentryEnvelope {
SentryTraceContextHeader? traceContext,
List<SentryAttachment>? attachments,
}) {
final isUnhandledException =
event.exceptions?.first.mechanism?.handled == false;
bool containsUnhandledException = false;

if (event.exceptions != null && event.exceptions!.isNotEmpty) {
// Check all exceptions for any unhandled ones
containsUnhandledException = event.exceptions!.any((exception) {
return exception.mechanism?.handled == false;
});
}

return SentryEnvelope(
SentryEnvelopeHeader(
event.eventId,
Expand All @@ -47,7 +54,7 @@ class SentryEnvelope {
if (attachments != null)
...attachments.map((e) => SentryEnvelopeItem.fromAttachment(e))
],
containsUnhandledException: isUnhandledException,
containsUnhandledException: containsUnhandledException,
);
}

Expand Down
2 changes: 1 addition & 1 deletion flutter/test/sentry_native_channel_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ void main() {
(invocation) async =>
{captured = invocation.positionalArguments[1][0] as Uint8List});

await sut.captureEnvelope(data);
await sut.captureEnvelope(data, false);

expect(captured, data);
});
Expand Down