From 4a82e08752fd8ac7ad38002a1b1e4427f9be3f92 Mon Sep 17 00:00:00 2001 From: Mathieu Strypsteen Date: Thu, 7 Mar 2024 17:31:26 +0100 Subject: [PATCH] Remove unused file --- backend/routes/exception_handlers.py | 38 ---------------------------- 1 file changed, 38 deletions(-) delete mode 100644 backend/routes/exception_handlers.py diff --git a/backend/routes/exception_handlers.py b/backend/routes/exception_handlers.py deleted file mode 100644 index a0076c22..00000000 --- a/backend/routes/exception_handlers.py +++ /dev/null @@ -1,38 +0,0 @@ -from fastapi import Request, status -from fastapi.responses import JSONResponse - -from app import app -from db.errors.database_errors import ActionAlreadyPerformedError, ItemNotFoundError -from routes.errors.authentication import InvalidRoleCredentialsError, StudentNotEnrolledError - - -@app.exception_handler(InvalidRoleCredentialsError) -def invalid_admin_credentials_error_handler(request: Request, exc: InvalidRoleCredentialsError) -> JSONResponse: - return JSONResponse( - status_code=status.HTTP_403_FORBIDDEN, - content={"message": exc.ERROR_MESSAGE}, - ) - - -@app.exception_handler(ItemNotFoundError) -def item_not_found_error_handler(request: Request, exc: ItemNotFoundError) -> JSONResponse: - return JSONResponse( - status_code=status.HTTP_404_NOT_FOUND, - content={"detail": str(exc)}, - ) - - -@app.exception_handler(StudentNotEnrolledError) -def student_already_enrolled_error_handler(request: Request, exc: StudentNotEnrolledError) -> JSONResponse: - return JSONResponse( - status_code=status.HTTP_400_BAD_REQUEST, - content={"detail": str(exc)}, - ) - - -@app.exception_handler(ActionAlreadyPerformedError) -def action_already_performed_error_handler(request: Request, exc: ActionAlreadyPerformedError) -> JSONResponse: - return JSONResponse( - status_code=status.HTTP_400_BAD_REQUEST, - content={"detail": str(exc)}, - )