onError method

  1. @override
Future<void> onError(
  1. DioException err,
  2. ErrorInterceptorHandler handler
)
override

Called when an exception was occurred during the request.

Implementation

@override
Future<void> onError(
  DioException err,
  ErrorInterceptorHandler handler,
) async {
  final int? statusCode = err.response?.statusCode;
  if (statusCode == HttpStatus.unauthorized ||
      statusCode == HttpStatus.forbidden) {
    // TODO(all):  implement usage of refresh token instead of logout
    // GetIt.I.get<AuthenticationBloc>().add(
    //       const AuthenticationEvent.loggedOut(),
    //     );
  } else {
    return handler.next(err);
  }
}