add error Listener

This commit is contained in:
toki 2023-03-17 06:43:14 +09:00
parent 15f9a9aa70
commit 7ec471f990

View file

@ -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');
}
}