diff --git a/lib/data/api/api_client.dart b/lib/data/api/api_client.dart index 1419f92..e88b917 100644 --- a/lib/data/api/api_client.dart +++ b/lib/data/api/api_client.dart @@ -44,6 +44,16 @@ class _ErrorInterceptor extends Interceptor { )); return; } + if (err.type == DioExceptionType.receiveTimeout || + err.type == DioExceptionType.sendTimeout) { + handler.reject(DioException( + requestOptions: err.requestOptions, + error: const AppException('Request timed out. The server is taking too long to respond.'), + type: err.type, + response: err.response, + )); + return; + } handler.next(err); } } diff --git a/lib/data/api/quick_capture_api.dart b/lib/data/api/quick_capture_api.dart index 19ca190..485b28c 100644 --- a/lib/data/api/quick_capture_api.dart +++ b/lib/data/api/quick_capture_api.dart @@ -40,6 +40,7 @@ class QuickCaptureApi { final response = await _dio.post( '/api/quick-capture', data: {'text': text}, + options: Options(receiveTimeout: const Duration(seconds: 120)), ); return CaptureResult.fromJson(response.data as Map); } on DioException catch (e) {