From e1399ce46ae55cdfea0e8826b4f09fd94e081c86 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Fri, 15 Mar 2024 10:42:40 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20Remove=20another=20`.catchError`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dio/lib/src/dio_mixin.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dio/lib/src/dio_mixin.dart b/dio/lib/src/dio_mixin.dart index 3c7db7fb6..9c5507b36 100644 --- a/dio/lib/src/dio_mixin.dart +++ b/dio/lib/src/dio_mixin.dart @@ -503,12 +503,13 @@ abstract class DioMixin implements Dio { future = future.catchError(errorInterceptorWrapper(fun)); } // Normalize errors, converts errors to [DioException]. - return future.then>((data) { + try { + final data = await future; return assureResponse( data is InterceptorState ? data.data : data, requestOptions, ); - }).catchError((Object e) { + } catch (e) { final isState = e is InterceptorState; if (isState) { if (e.type == InterceptorResultType.resolve) { @@ -516,7 +517,7 @@ abstract class DioMixin implements Dio { } } throw assureDioException(isState ? e.data : e, requestOptions); - }); + } } Future> _dispatchRequest(RequestOptions reqOpt) async {