From c41e6b32a7eb45781c1c520ff9f28769336aa9c1 Mon Sep 17 00:00:00 2001 From: Felipe Allegretti Date: Tue, 23 Jan 2024 14:34:16 -0300 Subject: [PATCH] Implement ConnectionError handler (#57) --- app/services/base.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/services/base.py b/app/services/base.py index de1119d..fe5300f 100644 --- a/app/services/base.py +++ b/app/services/base.py @@ -58,6 +58,10 @@ def make_request(self, url: Optional[str] = None) -> Response: ) except TooManyRedirects: raise HTTPException(status_code=404, detail=f"Not found for url: {url}") + except ConnectionError: + raise HTTPException(status_code=500, detail=f"Connection error for url: {url}") + except Exception as e: + raise HTTPException(status_code=500, detail=f"Error for url: {url}. {e}") if 400 <= response.status_code < 500: raise HTTPException( status_code=response.status_code,