You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sentry automatically captures uncaught exceptions.
Exceptions you catch urself aren't usually needed to be reported because you're handling themself and thus aren't really bad. Though there's nothing stopping from reporting them, too. If you're catching them yourself you need to use Sentry.captureException.
You don't need to add a runZoneGuarded. SentryFlutter does this for you if you're using the appRunner callback like in your example.
Also SentryFlutter automatically listens to FlutterError.onError, so you don't need that to do it yourself.
A minimal example with automatic capturing for runZoneGuarded and FlutterError.onError looks like this:
Just started using this and the documentation is confusing.
I assume it would automatically work, but it seems I have to put Sentry.captureException in every catch()? All over my code?
I see in the docs it says "Sentry's Flutter SDK enables automatic reporting of errors, messages, and exceptions"
Is it automatic or not? If I remove the Sentry.captureException, nothing happens, so it doesn't seem automatic to me.
I saw this in another issue. Do I need runZonedGuarded for it to work?
FlutterError.onError = (FlutterErrorDetails details,) async {
if (!isProduction) {
FlutterError.dumpErrorToConsole(details);
return;
}
// turn to Zone
Zone.current.handleUncaughtError(details.exception, details.stack);
};
// Handle dart error
runZonedGuarded<Future>(() async {
SentryFlutter.init((options) => options.dsn = 'xxx',
() {
runApp(MyApp());
},
);
}, (Object error, StackTrace stackTrace) async {
if (!isProduction) {
print(error);
print(stackTrace);
return;
}
// Only upload error on release mode
Sentry.captureException(
error,
stackTrace: stackTrace,
);
});
The text was updated successfully, but these errors were encountered: