import 'package:dio/dio.dart'; import 'api_exception.dart'; class KratosErrorInterceptor extends Interceptor { @override void onError(DioException err, ErrorInterceptorHandler handler) { if (err.error is ApiException) { handler.next(err); return; } // Preserve response.data for diagnostics and retries. The parsed error is // carried as DioException.error and normalized by ApiException.from(). handler.next(err.copyWith(error: ApiException.fromDio(err))); } }