2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-17 04:35:26 +00:00

Add extra context information to sentry error reports

- Should help to track down bugs where stacktrace is missing information
- Adds some more error catching, too
This commit is contained in:
Oliver Walters
2022-05-12 22:46:12 +10:00
parent e47d88a4bb
commit c90a849a5a
5 changed files with 69 additions and 13 deletions

View File

@ -142,7 +142,7 @@ Future<bool> sentryReportMessage(String message, {Map<String, String>? context})
}
Future<void> sentryReportError(dynamic error, dynamic stackTrace) async {
Future<void> sentryReportError(String source, dynamic error, dynamic stackTrace, {Map<String, String> context = const {}}) async {
print("----- Sentry Intercepted error: $error -----");
print(stackTrace);
@ -167,10 +167,14 @@ Future<void> sentryReportError(dynamic error, dynamic stackTrace) async {
final app_info = await getAppInfo();
final device_info = await getDeviceInfo();
// Ensure we pass the 'source' of the error
context["source"] = source;
Sentry.configureScope((scope) {
scope.setExtra("server", server_info);
scope.setExtra("app", app_info);
scope.setExtra("device", device_info);
scope.setExtra("context", context);
});
Sentry.captureException(error, stackTrace: stackTrace).catchError((error) {