request<T> method
Future<Response<T> >
request<T>(
- String path, {
- Object? data,
- Map<
String, dynamic> ? queryParameters, - Options? options,
- CancelToken? cancelToken,
- ProgressCallback? onSendProgress,
- ProgressCallback? onReceiveProgress,
override
If AppException is placed into DioException.error, then it will throw a nested AppException
Implementation
@override
Future<Response<T>> request<T>(
String path, {
Object? data,
Map<String, dynamic>? queryParameters,
Options? options,
CancelToken? cancelToken,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
try {
// All get/post/patch calls funnel through here
return await super.request<T>(
path,
data: data,
queryParameters: queryParameters,
options: options,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
} on DioException catch (e) {
// If your ValidationInterceptor stashed an ApiResponseException in .error,
// unwrap and throw it directly:
if (e.error is AppException) throw e.error as AppException;
// Otherwise, rethrow the original DioException
rethrow;
}
}