handleUncaughtError method Null safety
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,
throwin the function passed to Timer.run.
- Asynchronous errors that are pushed through Future and Stream chains, but for which no child 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.
void handleUncaughtError(Object error, StackTrace stackTrace);