Closed thesadboy closed 2 years ago
Hi @thesadboy ! Thank you for contributing. Can you please give an example when an existed code was working incorrectly?
import 'package:dio/dio.dart';
import 'package:dio_smart_retry/dio_smart_retry.dart';
main() async {
Dio dio = Dio();
dio.interceptors.add(RetryInterceptor(dio: dio, retries: 3, retryDelays: const [
Duration(seconds: 1),
Duration(seconds: 2),
Duration(seconds: 3),
]));
try {
var res = await dio.get('https://www.baidu.com');
print(res.data);
} catch (e) {
print('Error: $e');
}
}
and then , offline and run this code. We can't catch the error in the code.The console print is bellow:
/Users/Nick/fvm/versions/stable/bin/cache/dart-sdk/bin/dart --enable-asserts /Users/Nick/WorkSpace/WS-Apps/dio_smart_retry_test/lib/test.dart
lib/test.dart: Warning: Interpreting this as package URI, 'package:dio_smart_retry_test/test.dart'.
Unhandled exception:
DioError [DioErrorType.other]: SocketException: Failed host lookup: 'www.baidu.com' (OS Error: nodename nor servname provided, or not known, errno = 8)
#0 DioMixin.assureDioError (package:dio/src/dio_mixin.dart:821:20)
#1 DioMixin._dispatchRequest (package:dio/src/dio_mixin.dart:678:13)
<asynchronous suspension>
#2 DioMixin.fetch.<anonymous closure>.<anonymous closure> (package:dio/src/dio_mixin.dart)
<asynchronous suspension>
#0 DioMixin.fetch.<anonymous closure> (package:dio/src/dio_mixin.dart:618:7)
#1 _RootZone.runBinary (dart:async/zone.dart:1692:54)
#2 _FutureListener.handleError (dart:async/future_impl.dart:175:22)
#3 Future._propagateToListeners.handleError (dart:async/future_impl.dart:779:47)
#4 Future._propagateToListeners (dart:async/future_impl.dart:800:13)
#5 Future._completeError (dart:async/future_impl.dart:610:5)
#6 _SyncCompleter._completeError (dart:async/future_impl.dart:61:12)
#7 _Completer.completeError (dart:async/future_impl.dart:33:5)
#8 Future.any.onError (dart:async/future.dart:466:45)
#9 _RootZone.runBinary (dart:async/zone.dart:1692:54)
#10 _FutureListener.handleError (dart:async/future_impl.dart:175:22)
#11 Future._propagateToListeners.handleError (dart:async/future_impl.dart:779:47)
#12 Future._propagateToListeners (dart:async/future_impl.dart:800:13)
#13 Future._completeError (dart:async/future_impl.dart:610:5)
#14 Future._asyncCompleteError.<anonymous closure> (dart:async/future_impl.dart:666:7)
#15 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#16 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#17 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:120:13)
#18 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:402:11)
#19 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:426:5)
#20 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
Process finished with exit code 255
Yes, I see now. Thank you for a contributing.
when update?
when update?
Sorry for delay, updated.
fix retry uncatched error. if not, when error occurred, we can't catch error by dio.post or dio.get.