-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.closed-obsoleteClosed as the reported issue is no longer relevantClosed as the reported issue is no longer relevantcore-nlibrary-async
Description
I have a method runInApp(body()) that executes body in the (Angular) zone which is its own error zone.
runInApp(body()) => zone.run(body);zone.run calls angularZone.runGuarded(body) internally.
If something throws in body, it never passes the error zone boundary. This is particularly annoying in tests because they end up timing out without telling you about the exception.
The only way I've found to route errors through the error zone boundary is not very beautiful:
(It has to support async and sync body()s.)
runInApp(body()) {
var result;
var error;
var stackTrace;
var completer = new Completer();
zone.run(() {
try {
result = body();
if (result is Future) {
result.then((result) {
completer.complete(result);
}, onError: (e, st) {
completer.completeError(e, st);
});
result = completer.future;
}
} catch (e,st) {
error = e;
stackTrace = st;
}
});
if (error != null) {
print(stackTrace);
throw error;
}
return result;
}This feels rather cumbersome. Is there another way to handle this?
Also, there is no way to rethrow an exception in synchronous code that preserves the original stacktrace.
Metadata
Metadata
Assignees
Labels
area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.closed-obsoleteClosed as the reported issue is no longer relevantClosed as the reported issue is no longer relevantcore-nlibrary-async