fix: avoid sending internal server error message when 500
This commit is contained in:
parent
0dce6cf89a
commit
e887b1d357
1 changed files with 5 additions and 1 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import logging
|
||||
from datetime import datetime
|
||||
from typing import Annotated
|
||||
|
||||
|
|
@ -11,6 +12,8 @@ from dependencies import get_consumption_service
|
|||
|
||||
from ._readings_schemas import ConsumptionResponseSchema
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
readings_router = APIRouter(prefix="/readings", tags=["readings"])
|
||||
|
||||
DevEUI = Annotated[constr(max_length=64, pattern=r'^[0-9A-Fa-f]+$'), Path()]
|
||||
|
|
@ -29,4 +32,5 @@ def get_consumption(
|
|||
except ValidationError as e:
|
||||
raise HTTPException(status_code=422, detail=str(e))
|
||||
except DatabaseError as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
log.error("DatabaseError: %s", e)
|
||||
raise HTTPException(status_code=500, detail="Erreur interne du serveur")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue