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) {
  super.onError(err, handler);
  final accepted = settings.errorFilter?.call(err) ?? true;
  if (!accepted) {
    return;
  }
  try {
    final message = '${err.requestOptions.uri}';
    final httpErrorLog = DioErrorLog(
      message,
      dioException: err,
      settings: settings,
    );
    _talker.logTyped(httpErrorLog);
  } catch (_) {
    //pass
  }
}