onError method

  1. @override
Future onError (DioError dioError)

The callback will be executed on error.

If you want to resolve the request with some custom data, you can return a Response object or return dio.resolve. If you want to continue the request, return the DioError object.

Implementation

@override
Future onError(DioError dioError) async {
  print(
      '<-- ${dioError.message} ${(dioError.response?.request != null ? (dioError.response.request.baseUrl + dioError.response.request.path) : 'URL')}');
  print(
      '${dioError.response != null ? dioError.response.data : 'Unknown Error'}');
  print('<-- End error');

  return super.onError(dioError);
}