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 {