Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

[MISC] Add missing PresignedURLFetchError class to resolve import error (#1498)

Praveen Kumar22b204b7d1b1
diff --git a/backend/api_v2/exceptions.py b/backend/api_v2/exceptions.py
index 8be009b7a..7de9a20ab 100644
--- a/backend/api_v2/exceptions.py
+++ b/backend/api_v2/exceptions.py
@@ -56,3 +56,37 @@ class NoActiveAPIKeyError(APIException):
if detail is None:
detail = f"No active API keys configured for {deployment_name}"
super().__init__(detail, code)
+
+
+class PresignedURLFetchError(APIException):
+ default_detail = "Failed to fetch file from presigned URL"
+
+ def __init__(
+ self,
+ url: str = "",
+ error_message: str = "",
+ status_code: int = 400,
+ detail: str | None = None,
+ code: str | None = None,
+ ):
+ if detail is None:
+ detail = f"Failed to fetch file from URL: {url}. Error: {error_message}"
+
+ self.status_code = status_code
+ super().__init__(detail, code)
+
+ @classmethod
+ def from_response_error(cls, url: str, response_status: int, error_message: str = ""):
+ """Create exception with status code derived from HTTP response"""
+ return cls(url=url, error_message=error_message, status_code=response_status)
+
+ @classmethod
+ def from_request_exception(cls, url: str, exception: Exception):
+ """Create exception with status code inferred from exception type"""
+ status_code = 400 # default
+ if isinstance(exception, TimeoutError):
+ status_code = 504
+ elif "connection" in str(exception).lower():
+ status_code = 502
+
+ return cls(url=url, error_message=str(exception), status_code=status_code)