WrapError<St> class
abstract
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(() =>
Business.store.dispatch(UserExceptionAction.from(error.withoutHardCause())));
return hardCause;
}}
return null; }
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
wrap(
Object error, StackTrace stackTrace, ReduxAction< St> action) → Object?
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited