add error Listener
This commit is contained in:
parent
15f9a9aa70
commit
7ec471f990
1 changed files with 4 additions and 3 deletions
|
|
@ -3,15 +3,16 @@ import 'dart:async';
|
|||
import 'log.dart';
|
||||
|
||||
abstract class Application {
|
||||
Application(Function() func) {
|
||||
Application(Function() func, Function(Object, StackTrace) errorListener) {
|
||||
runZonedGuarded(() async {
|
||||
func();
|
||||
}, (error, stack) {
|
||||
writeInLog(error, stack);
|
||||
writeLog(error, stack);
|
||||
errorListener(error, stack);
|
||||
});
|
||||
}
|
||||
|
||||
void writeInLog(Object error, StackTrace stack) {
|
||||
void writeLog(Object error, StackTrace stack) {
|
||||
logError('$error:\n$stack');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue