request<T> method

  1. @override
Future<Response<T>> request<T>(
  1. String path, {
  2. Object? data,
  3. Map<String, dynamic>? queryParameters,
  4. Options? options,
  5. CancelToken? cancelToken,
  6. ProgressCallback? onSendProgress,
  7. 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;
  }
}