Sentry moved to lib. Catch markers errors

This commit is contained in:
Vicente J. Ruiz Jurado 2018-08-17 12:04:58 +02:00
parent f476a099f8
commit e6c3833765
4 changed files with 103 additions and 43 deletions

25
lib/sentryReport.dart Normal file
View file

@ -0,0 +1,25 @@
import 'dart:async';
import 'package:flutter_simple_dependency_injection/injector.dart';
import 'package:sentry/sentry.dart';
import 'globals.dart' as globals;
var useSentry = !globals.isDevelopment;
Future<Null> reportError(dynamic error, dynamic stackTrace) async {
// Print the exception to the console
print('Caught error: $error');
if (!useSentry) {
// Print the full stacktrace in debug mode
print(stackTrace);
return;
} else {
// Send the Exception and Stacktrace to Sentry in Production mode
Injector.getInjector().get<SentryClient>().captureException(
exception: error,
stackTrace: stackTrace,
);
}
}