hotfix: Capture Exception

This commit is contained in:
Christian Pauly 2020-10-04 11:52:06 +02:00
parent c8d3c9d614
commit 028b1e4ed8
3 changed files with 28 additions and 22 deletions

View File

@ -15,6 +15,7 @@ import 'package:localstorage/localstorage.dart';
import 'package:universal_html/prefer_universal/html.dart' as html; import 'package:universal_html/prefer_universal/html.dart' as html;
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
import '../main.dart';
import '../utils/app_route.dart'; import '../utils/app_route.dart';
import '../utils/beautify_string_extension.dart'; import '../utils/beautify_string_extension.dart';
import '../utils/famedlysdk_store.dart'; import '../utils/famedlysdk_store.dart';
@ -83,6 +84,7 @@ class MatrixState extends State<Matrix> {
void _initWithStore() async { void _initWithStore() async {
var initLoginState = client.onLoginStateChanged.stream.first; var initLoginState = client.onLoginStateChanged.stream.first;
try {
client.database = await getDatabase(client); client.database = await getDatabase(client);
client.connect(); client.connect();
if (await initLoginState == LoginState.logged && PlatformInfos.isMobile) { if (await initLoginState == LoginState.logged && PlatformInfos.isMobile) {
@ -92,6 +94,10 @@ class MatrixState extends State<Matrix> {
); );
} }
_cleanUpUserStatus(userStatuses); _cleanUpUserStatus(userStatuses);
} catch (e, s) {
client.onLoginStateChanged.sink.addError(e, s);
captureException(e, s);
}
} }
Map<String, dynamic> getAuthByPassword(String password, [String session]) => { Map<String, dynamic> getAuthByPassword(String password, [String session]) => {

View File

@ -18,12 +18,7 @@ import 'views/chat_list.dart';
final sentry = SentryClient(dsn: '8591d0d863b646feb4f3dda7e5dcab38'); final sentry = SentryClient(dsn: '8591d0d863b646feb4f3dda7e5dcab38');
void main() { void captureException(error, stackTrace) async {
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(statusBarColor: Colors.transparent));
runZonedGuarded(
() => runApp(App()),
(error, stackTrace) async {
final storage = LocalStorage('LocalStorage'); final storage = LocalStorage('LocalStorage');
await storage.ready; await storage.ready;
debugPrint(error.toString()); debugPrint(error.toString());
@ -34,7 +29,14 @@ void main() {
stackTrace: stackTrace, stackTrace: stackTrace,
); );
} }
}, }
void main() {
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(statusBarColor: Colors.transparent));
runZonedGuarded(
() => runApp(App()),
captureException,
); );
} }

View File

@ -36,8 +36,6 @@ Future<Database> getDatabase(Client client) async {
await store.setItem('database-password', password); await store.setItem('database-password', password);
} }
return _db; return _db;
} catch (_) {
rethrow;
} finally { } finally {
_generateDatabaseLock = false; _generateDatabaseLock = false;
} }