onError method

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

Called when an exception was occurred during the request.

Implementation

@override
void onError(DioException err, ErrorInterceptorHandler handler) async {
  if (showLogging) {
    if (kDebugMode) {
      print(
          'OS BASECODE - ERROR[${err.response?.statusCode}] => PATH: ${err.requestOptions.path}');
      print('OS BASECODE - FULL ERROR: ${err.toString()}');
      print('OS BASECODE - ERROR MESSAGE : ${err.message}');
      print('OS BASECODE - ERROR TRACE : ${err.stackTrace}');
    }
  }
  handleOnError(err, handler);
  if (err.response?.statusCode == 401) {
    handleWhenUnauthorized();
  }

  return super.onError(err, handler);
}