makefile and http errors
This commit is contained in:
@@ -11,4 +11,30 @@ class Errors:
|
||||
raise HTTPException(status_code=403, detail=detail, headers={"Cache-Control": "no-store, max-age=0"})
|
||||
|
||||
def not_found_error(self, detail:str)->HTTPException:
|
||||
raise HTTPException(status_code=404, detail=detail, headers={"Cache-Control": "no-store, max-age=0"})
|
||||
raise HTTPException(status_code=404, detail=detail, headers={"Cache-Control": "no-store, max-age=0"})
|
||||
|
||||
def conflict_error(self, detail:str)->HTTPException:
|
||||
raise HTTPException(status_code=409, detail=detail)
|
||||
|
||||
def bad_request_error(self, detail:str) -> HTTPException:
|
||||
raise HTTPException(status_code=400, detail=detail)
|
||||
|
||||
def validation_error(self, detail:str) -> HTTPException:
|
||||
raise HTTPException(status_code=422, detail=detail)
|
||||
|
||||
def rate_limit_error(self, detail:str, retry_after: int = 60) -> HTTPException:
|
||||
raise HTTPException(
|
||||
status_code=429,
|
||||
detail=detail,
|
||||
headers={"Retry-After":str(retry_after)}
|
||||
)
|
||||
|
||||
def internal_server_error(self, detail:str = "Internal server error") -> HTTPException:
|
||||
raise HTTPException(status_code=500, detail=detail)
|
||||
|
||||
def service_unavailable_error(self, detail:str, retry_after: int = 30) -> HTTPException:
|
||||
raise HTTPException(
|
||||
status_code=503,
|
||||
detail=detail,
|
||||
headers={"Retry-After":str(retry_after)}
|
||||
)
|
||||
Reference in New Issue
Block a user