onError method

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

Called when an exception was occurred during the request.

Implementation

@override
void onError(DioException err, ErrorInterceptorHandler handler) {
  CommonWidgets.logPrint('*** Api Error - Start ***:');

  CommonWidgets.logPrint('URI: ${err.requestOptions.uri}');
  if (err.response != null) {
    CommonWidgets.logPrint(
        'STATUS CODE: ${err.response?.statusCode?.toString()}');
  }
  CommonWidgets.logPrint('$err');
  if (err.response != null) {
    printKV('REDIRECT', err.response?.realUri ?? '');
    CommonWidgets.logPrint('BODY:');
    printAll(err.response?.data.toString());
  }

  CommonWidgets.logPrint('*** Api Error - End ***:');
  return handler.next(err);
}