From 7ec471f990999ff2e77fa39cb60df575268af484 Mon Sep 17 00:00:00 2001 From: toki Date: Fri, 17 Mar 2023 06:43:14 +0900 Subject: [PATCH] add error Listener --- lib/core/application.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/core/application.dart b/lib/core/application.dart index a6d6aaf..5b34c5c 100644 --- a/lib/core/application.dart +++ b/lib/core/application.dart @@ -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'); } }