This commit is contained in:
@@ -33,7 +33,7 @@ def get_product(
|
||||
):
|
||||
result = service.get_one(session, id)
|
||||
if result is None:
|
||||
raise HTTPException(status_code=404, detail=messages.notfound)
|
||||
raise HTTPException(status_code=404, detail=messages.Messages.not_found('product'))
|
||||
return result
|
||||
|
||||
@router.post('', response_model=models.ProductPublic)
|
||||
@@ -44,10 +44,10 @@ def create_product(
|
||||
):
|
||||
try:
|
||||
result = service.create_one(session, product)
|
||||
except exceptions.ProductCreateError:
|
||||
raise HTTPException(status_code=400, detail=messages.productinputinvalid)
|
||||
except exceptions.ProductorNotFoundError:
|
||||
raise HTTPException(status_code=404, detail=messages.productornotfound)
|
||||
except exceptions.ProductCreateError as error:
|
||||
raise HTTPException(status_code=400, detail=str(error))
|
||||
except exceptions.ProductorNotFoundError as error:
|
||||
raise HTTPException(status_code=404, detail=str(error))
|
||||
return result
|
||||
|
||||
@router.put('/{id}', response_model=models.ProductPublic)
|
||||
@@ -58,10 +58,10 @@ def update_product(
|
||||
):
|
||||
try:
|
||||
result = service.update_one(session, id, product)
|
||||
except exceptions.ProductNotFoundError:
|
||||
raise HTTPException(status_code=404, detail=messages.productnotfound)
|
||||
except exceptions.ProductorNotFoundError:
|
||||
raise HTTPException(status_code=404, detail=messages.productornotfound)
|
||||
except exceptions.ProductNotFoundError as error:
|
||||
raise HTTPException(status_code=404, detail=str(error))
|
||||
except exceptions.ProductorNotFoundError as error:
|
||||
raise HTTPException(status_code=404, detail=str(error))
|
||||
return result
|
||||
|
||||
@router.delete('/{id}', response_model=models.ProductPublic)
|
||||
@@ -72,6 +72,6 @@ def delete_product(
|
||||
):
|
||||
try:
|
||||
result = service.delete_one(session, id)
|
||||
except exceptions.ProductNotFoundError:
|
||||
raise HTTPException(status_code=404, detail=messages.notfound)
|
||||
except exceptions.ProductNotFoundError as error:
|
||||
raise HTTPException(status_code=404, detail=str(error))
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user