Skip to content

Mark exceptions not handled by user as handled: false #1535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## Unreleased

### Feature

- Mark exceptions not handled by user as `handled: false` ([#1535](https://github.com/getsentry/sentry-dart/pull/1535))
- This will affect your release health data, and is therefore considered a breaking change.

## 7.8.0

### Enhancements
Expand Down
4 changes: 2 additions & 2 deletions dart/lib/src/run_zoned_guarded_integration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class RunZonedGuardedIntegration extends Integration<SentryOptions> {
stackTrace: stackTrace,
);

// runZonedGuarded doesn't crash the App.
final mechanism = Mechanism(type: 'runZonedGuarded', handled: true);
// runZonedGuarded doesn't crash the app, but is not handled by the user.
final mechanism = Mechanism(type: 'runZonedGuarded', handled: false);
final throwableMechanism = ThrowableMechanism(mechanism, exception);

final event = SentryEvent(
Expand Down
5 changes: 3 additions & 2 deletions dart/lib/src/sentry_isolate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ class SentryIsolate {
stackTrace == null ? null : StackTrace.fromString(stackTrace),
);

// Isolate errors don't crash the App.
final mechanism = Mechanism(type: 'isolateError', handled: true);
// Isolate errors don't crash the app, but is not handled by the user.
final mechanism = Mechanism(type: 'isolateError', handled: false);
final throwableMechanism = ThrowableMechanism(mechanism, throwable);

final event = SentryEvent(
throwable: throwableMechanism,
level: SentryLevel.fatal,
Expand Down
2 changes: 1 addition & 1 deletion flutter/ios/sentry_flutter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Sentry SDK for Flutter with support to native through sentry-cocoa.
:tag => s.version.to_s }
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Sentry/HybridSDK', '8.8.0'
s.dependency 'Sentry/HybridSDK', '8.9.1'
s.ios.dependency 'Flutter'
s.osx.dependency 'FlutterMacOS'
s.ios.deployment_target = '11.0'
Expand Down
7 changes: 2 additions & 5 deletions flutter/lib/src/integrations/flutter_error_integration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,8 @@ class FlutterErrorIntegration implements Integration<SentryFlutterOptions> {
stackTrace: errorDetails.stack,
);

// FlutterError doesn't crash the App.
final mechanism = Mechanism(
type: 'FlutterError',
handled: true,
);
// FlutterError doesn't crash the app, but is not handled by the user.
final mechanism = Mechanism(type: 'FlutterError', handled: false);
final throwableMechanism = ThrowableMechanism(mechanism, exception);

var event = SentryEvent(
Expand Down
6 changes: 3 additions & 3 deletions flutter/test/integrations/flutter_error_integration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void main() {

final throwableMechanism = event.throwableMechanism as ThrowableMechanism;
expect(throwableMechanism.mechanism.type, 'FlutterError');
expect(throwableMechanism.mechanism.handled, true);
expect(throwableMechanism.mechanism.handled, false);
expect(throwableMechanism.throwable, exception);

expect(event.contexts['flutter_error_details']['library'], 'sentry');
Expand Down Expand Up @@ -102,7 +102,7 @@ void main() {

final throwableMechanism = event.throwableMechanism as ThrowableMechanism;
expect(throwableMechanism.mechanism.type, 'FlutterError');
expect(throwableMechanism.mechanism.handled, true);
expect(throwableMechanism.mechanism.handled, false);

expect(event.contexts['flutter_error_details']['library'], 'sentry');
expect(event.contexts['flutter_error_details']['context'],
Expand All @@ -126,7 +126,7 @@ void main() {

final throwableMechanism = event.throwableMechanism as ThrowableMechanism;
expect(throwableMechanism.mechanism.type, 'FlutterError');
expect(throwableMechanism.mechanism.handled, true);
expect(throwableMechanism.mechanism.handled, false);
expect(throwableMechanism.mechanism.data['hint'], isNull);

expect(event.contexts['flutter_error_details'], isNull);
Expand Down