Closed frank06 closed 4 years ago
Hum onError could default to Zone.current.handleUncaughtError
notifier.onError = Zone.current.handleUncaughtError;
does indeed work. Thank you Remi for the speedy response and the black magic!
I'll make a pr that makes it the default
@rrousselGit would it be possible to just throw error
? Debugging errors inside listeners is a pain
What do you mean by pain?
There was an exception thrown inside a listener and there was no way to trace back to the line that caused it. Debugger jumped to the state_notifier
package line with throw Error()
, arguments error
and stackTrace
are not helpful.
Using 0.5.0
Why not throw the error directly?
try {
listenerEntry.listener(value);
} catch (error, stackTrace) {
if (onError != null) {
onError(error, stackTrace);
} else {
throw error;
}
}
It notifies all listeners first. Otherwise some listeners could be left out
I am testing stuff inside of the
addListener
callback, but since errors are caught and "redirected" toonError
, test failures are never exposed:Any of those
expect
s failing, and the test will still pass.I tried different ways of overriding the callback but none report back the failure:
So my first workaround is checking on the counter at the end of the test:
Any better ideas or workarounds?