handleUncaughtError abstract method Null safety

void handleUncaughtError(
  1. Object error,
  2. StackTrace stackTrace
)

Handles uncaught asynchronous errors.

There are two kind of asynchronous errors that are handled by this function:

  1. Uncaught errors that were thrown in asynchronous callbacks, for example, a throw in the function passed to Timer.run.
  2. 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);