mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-15 07:56:11 +08:00

And hopefully add some more context to some async stack traces that don't make any sense.
38 lines
1.1 KiB
Dart
38 lines
1.1 KiB
Dart
import 'dart:async';
|
|
import 'dart:isolate';
|
|
|
|
import 'package:flutter/foundation.dart' as foundation;
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:stack_trace/stack_trace.dart';
|
|
|
|
import 'package:gitjournal/app.dart';
|
|
import 'package:gitjournal/app_settings.dart';
|
|
import 'package:gitjournal/error_reporting.dart';
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
var pref = await SharedPreferences.getInstance();
|
|
AppSettings.instance.load(pref);
|
|
|
|
JournalApp.isInDebugMode = foundation.kDebugMode;
|
|
FlutterError.onError = flutterOnErrorHandler;
|
|
|
|
Isolate.current.addErrorListener(RawReceivePort((dynamic pair) async {
|
|
var isolateError = pair as List<dynamic>;
|
|
assert(isolateError.length == 2);
|
|
assert(isolateError.first.runtimeType == Error);
|
|
assert(isolateError.last.runtimeType == StackTrace);
|
|
|
|
await reportError(isolateError.first, isolateError.last);
|
|
}).sendPort);
|
|
|
|
runZonedGuarded(() async {
|
|
await Chain.capture(() async {
|
|
await JournalApp.main(pref);
|
|
});
|
|
}, reportError);
|
|
}
|