getError method

Exception? getError([
  1. Object? error
])

Returns the last error that may occurred. Records an error as well.

Implementation

Exception? getError([Object? error]) {
  // Return the stored exception
  Exception? ex;
  if (_error != null) {
    ex = _error as Exception;
  }
  // Empty the stored exception
  if (error == null) {
    _error = null;
  } else {
    if (error is! Exception) {
      error = Exception(error.toString());
    }
    _error = error;
  }
  // Return the exception just past if any.
  if (ex == null && error != null) {
    ex = error as Exception;
  }
  return ex;
}