when using "handler.reject(error);" in onError of interceptors, I cannot DioException in .catchError(), but find it in .then().
Package
dio
Version
5.5.0+1
Operating-System
Android, Web
Adapter
Default Dio
Output of flutter doctor -v
[√] Flutter (Channel stable, 3.22.2, on Microsoft Windows [版本 10.0.22631.3880], locale zh-CN)
• Flutter version 3.22.2 on channel stable at D:\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 761747bfc5 (7 weeks ago), 2024-06-05 22:15:13 +0200
• Engine revision edd8546116
• Dart version 3.4.3
• DevTools version 2.34.3
[√] Windows Version (Installed version of Windows is version 10 or higher)
[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
• Android SDK at C:\Users\14732\AppData\Local\Android\sdk
X cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
X Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[X] Visual Studio - develop Windows apps
X Visual Studio not installed; this is necessary to develop Windows apps.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2024.1)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.10+0--11609105)
[√] Connected device (3 available)
• XIAOMI(mobile) • 192.168.1.209:8888 • android-arm64 • Android 12 (API 32)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [版本 10.0.22631.3880]
• Edge (web) • edge • web-javascript • Microsoft Edge 126.0.2592.113
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
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: @.***>