onError method

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

Called when an exception was occurred during the request.

Implementation

@override
void onError(DioError err, ErrorInterceptorHandler handler) {
  int duration = DateTime.now().difference(_startTime!).inMilliseconds;
  _log.write(
      '${'✖' * 20}     请求错误: ${(duration / 1000).toStringAsFixed(4)} 秒    ${'✖' * 20}\n');
  _log.write('-DioError :$err\n');
  printError(_log.toString(), extra);
  handler.next(err);
}