diff --git a/cope2n-api/fwd_api/api/ctel_view.py b/cope2n-api/fwd_api/api/ctel_view.py index 999ae17..d253c7a 100755 --- a/cope2n-api/fwd_api/api/ctel_view.py +++ b/cope2n-api/fwd_api/api/ctel_view.py @@ -19,7 +19,7 @@ from ..annotation.api import throw_on_failure from ..constant.common import allowed_p_type, ProcessType, REQUEST_ID, FOLDER_TYPE, \ FolderFileType, TEMPLATE_ID, EntityStatus, standard_ocr_list, pdf_extensions, image_extensions, allowed_file_extensions from ..exception.exceptions import RequiredFieldException, InvalidException, NotFoundException, \ - PermissionDeniedException, LimitReachedException, LockedEntityException, FileContentInvalidException + PermissionDeniedException, LimitReachedException, LockedEntityException, FileContentInvalidException, ServiceTimeoutException from ..models import SubscriptionRequest, UserProfile, SubscriptionRequestFile, OcrTemplate, Subscription from ..response.ReportSerializer import ReportSerializer from ..utils import FileUtils, ProcessUtil @@ -284,7 +284,7 @@ class CtelViewSet(viewsets.ViewSet): continue return Response(status=status.HTTP_200_OK, data=serializer.data[0]) - return JsonResponse(status=status.HTTP_504_GATEWAY_TIMEOUT, data={"status": "timeout",f"request_id": "{rq_id}"}) + raise ServiceTimeoutException(excArgs=f"{rq_id}") @extend_schema(request=None, responses=None, tags=['data']) diff --git a/cope2n-api/fwd_api/exception/exceptions.py b/cope2n-api/fwd_api/exception/exceptions.py index 1a7b1ad..6a71863 100755 --- a/cope2n-api/fwd_api/exception/exceptions.py +++ b/cope2n-api/fwd_api/exception/exceptions.py @@ -41,6 +41,11 @@ class ServiceUnavailableException(GeneralException): default_code = 5030 default_detail = 'Service temporarily unavailable, try again later.' +class ServiceTimeoutException(GeneralException): + status_code = 503 + default_code = 5031 + default_detail = 'Timeout waiting for the result, try again later.' + detail_with_arg = '{}' class LockedEntityException(GeneralException): status_code = status.HTTP_423_LOCKED