AsyncError errorCallback(Object error, StackTrace stackTrace)

Intercepts errors when added programmtically to a Future or Stream.

When caling Completer.completeError, Stream.addError, or Future constructors that take an error or a callback that may throw, the current zone is allowed to intercept and replace the error.

When other libraries use intermediate controllers or completers, such calls may contain errors that have already been processed.

Return null if no replacement is desired. The original error is used unchanged in that case. Otherwise return an instance of AsyncError holding the new pair of error and stack trace. If the AsyncError.error is null, it is replaced by a NullThrownError.

Source

AsyncError errorCallback(Object error, StackTrace stackTrace);