triggerError method

AsyncReply<T> triggerError(
  1. Exception exception
)

Implementation

AsyncReply<T> triggerError(Exception exception) {
  if (_resultReady) return this;

  if (exception is AsyncException)
    _exception = exception;
  else
    _exception = AsyncException.toAsyncException(exception);

  ///lock (callbacksLock)
  //{

  if (this._errorCallbacks.length == 0)
    throw _exception as AsyncException;
  else
    _errorCallbacks.forEach((x) {
      if (x is Function(dynamic, dynamic)) {
        x(_exception, null);
      } else if (x is Function(dynamic)) {
        x(_exception);
      } else if (x is Function()) {
        x();
      } else if (x is Function(Object, StackTrace)) {
        x(_exception as Object, StackTrace.current);
      }
      //x(_exception as AsyncException);
    });
  //}

  return this;
}