18 lines
384 B
Dart
18 lines
384 B
Dart
import 'dart:async';
|
|
|
|
import 'log.dart';
|
|
|
|
abstract class Application {
|
|
Application(Function() func, Function(Object, StackTrace) errorListener) {
|
|
runZonedGuarded(() async {
|
|
func();
|
|
}, (error, stack) {
|
|
writeLog(error, stack);
|
|
errorListener(error, stack);
|
|
});
|
|
}
|
|
|
|
void writeLog(Object error, StackTrace stack) {
|
|
logError('$error:\n$stack');
|
|
}
|
|
}
|