WrapError<St> class Null safety

This wrapper will be given all errors (including of type UserException).

  • If it returns something, it will be used instead of the original exception.
  • Otherwise, just return null, so that the original exception will not be modified.

Note this wrapper is called AFTER ReduxAction.wrapError, and BEFORE the ErrorObserver.

A common use case for this is to have a global place to convert some exceptions into UserExceptions. For example, Firebase may throw some PlatformExceptions in response to a bad connection to the server. In this case, you may want to show the user a dialog explaining that the connection is bad, which you can do by converting it to a UserException. Note, this could also be done in the ReduxAction.wrapError, but then you'd have to add it to all actions that use Firebase.

Another use case is when you want to throw the UserException.cause which is not itself an UserException, and you still want to show the original UserException in a dialog to the user:

Object wrap(Object error, [StackTrace stackTrace, ReduxAction<St> action]) {
  if (error is UserException) {
    var hardCause = error.hardCause();
    if (hardCause != null) {
      Future.microtask(() =>
      return hardCause;
  return null; }




hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
toString() String
A string representation of this object. [...]
wrap(Object error, StackTrace stackTrace, ReduxAction<St> action) Object?


operator ==(Object other) bool
The equality operator. [...]