onError<E extends Object> method

ValueCell<T> onError<E extends Object>(
  1. ValueCell<T> other
)

Create a cell which handles exceptions thrown while computing the value of this.

If an exception is thrown while computing the value of this, the cell returns the value of other.

E is the type of exception to handle. By default, if this is not explicitly given, all exceptions are handled.

A keyed cell is returned, which is unique for a given this, other and exception type E.

Implementation

ValueCell<T> onError<E extends Object>(ValueCell<T> other) => ValueCell.computed(() {
  try {
    return this();
  }
  on E {
    return other();
  }
}, key: _OnErrorKey<E>(this, other));