0.1.0
This commit is contained in:
1
src/errors/__init__.py
Normal file
1
src/errors/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
'''error handling classes'''
|
||||
14
src/errors/http_errors/errors.py
Normal file
14
src/errors/http_errors/errors.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from fastapi import HTTPException
|
||||
|
||||
|
||||
class Errors:
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
def credentials_error(self, detail:str)->HTTPException:
|
||||
raise HTTPException(status_code=401, detail=detail, headers={"WWW-Authenticate":"Bearer"})
|
||||
|
||||
def forbidden_error(self,detail:str)->HTTPException:
|
||||
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"})
|
||||
Reference in New Issue
Block a user