onError method

  1. @override
void onError(
  1. Object error,
  2. StackTrace stackTrace
)
override

Called whenever an error occurs and notifies BlocObserver.onError.

Note: super.onError should always be called last.

@override
void onError(Object error, StackTrace stackTrace) {
  // Custom onError logic goes here

  // Always call super.onError with the current error and stackTrace
  super.onError(error, stackTrace);
}

Implementation

@override
// ignore: must_call_super
void onError(Object error, StackTrace stackTrace) {
  if (error is MethodExecutionException) {
    error.complete();
    emit(RemoteModel.error(error.error));
  } else {
    emit(RemoteModel.error(error));
  }
}