safeAddError method

bool safeAddError(
  1. Object error, [
  2. StackTrace? stackTrace
])

Adds an error (with an optional stackTrace) to this controller if it is not closed.

Returns true if the error was added successfully, or false if the controller was closed.

Implementation

bool safeAddError(Object error, [StackTrace? stackTrace]) {
  if (isClosed) return false;
  try {
    addError(error, stackTrace);
    return true;
  } catch (e) {
    return false;
  }
}