handleUncaughtError method
- Object error,
- StackTrace stackTrace
Handles uncaught asynchronous errors.
There are two kind of asynchronous errors that are handled by this function:
- Uncaught errors that were thrown in asynchronous callbacks, for example, a
throw
in the function passed to Timer.run. - Asynchronous errors that are pushed through Future and Stream chains, but for which nobody registered an error handler. Most asynchronous classes, like Future or Stream push errors to their listeners. Errors are propagated this way until either a listener handles the error (for example with Future.catchError), or no listener is available anymore. In the latter case, futures and streams invoke the zone's handleUncaughtError.
By default, when handled by the root zone, uncaught asynchronous errors are treated like uncaught synchronous exceptions.
Implementation
void handleUncaughtError(Object error, StackTrace stackTrace);
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.13.0/dart-async/Zone/handleUncaughtError.html