Closed deidei1231 closed 3 weeks ago
Please provide a minimal reproducible example.
received
小David @.***
------------------ 原始邮件 ------------------ 发件人: "Alex @.>; 发送时间: 2024年10月7日(星期一) 上午10:16 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [cfug/dio] when using "handler.reject(error);" in onError of interceptors, I cannot DioException in .catchError(), but find it in .then(). (Issue #2273)
Closed #2273 as not planned.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
Package
dio
Version
5.5.0+1
Operating-System
Android, Web
Adapter
Default Dio
Output of
flutter doctor -v
Dart Version
No response
Steps to Reproduce
// in dio_request.dart _dio.interceptors.add( InterceptorsWrapper( onRequest: (RequestOptions options, RequestInterceptorHandler handler) { return handler.next(options); }, onResponse: (Response response, ResponseInterceptorHandler handler) { print(1111); return handler.next(response); }, onError: (DioException error, ErrorInterceptorHandler handler) { print(2222); return handler.reject(error); }, ), );
// in login.dart await Request().request("/login", method: DioMethod.post, data: { "account": data['username'], "password": data['password'], }).then((res){ print(3333); print(response is DioException); // the actual result is ture }).catchError((e){ print(4444); print(e); });
Expected Result
when I write "return handler.reject(error);" in onError of interceptors, I can find the DioException in ".catchError()", When the error.response,statuscode returned by the server is 400, the print execution order: 2222 4444
Actual Result
when I write "return handler.reject(error);" in onError of interceptors, I can find the DioException in ".then()". The print execution order: 2222 1111