File size: 1,468 Bytes
2ecc792
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5cd9bab
 
 
 
 
2ecc792
dce75a4
 
 
 
 
 
2ecc792
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from backend import app
from .Exceptions import *

from fastapi.responses import JSONResponse
from fastapi.requests import Request
from fastapi import status



@app.exception_handler(ExistingUserException)
async def handle_existing_user_found(request: Request, exec: ExistingUserException):
    return JSONResponse(status_code=status.HTTP_226_IM_USED,
                        content=repr(exec)
                        )

@app.exception_handler(EmailNotVerifiedException)
async def email_not_verified(request: Request, exec: EmailNotVerifiedException):
    return JSONResponse(status_code=status.HTTP_403_FORBIDDEN,
                        content=repr(exec)
                        )

@app.exception_handler(EmailNotSentException)
async def email_not_sent(request: Request, exec: EmailNotSentException):
    return JSONResponse(status_code=status.HTTP_403_FORBIDDEN,
                        content=repr(exec)
                        )

@app.exception_handler(InvalidCredentialsException)
async def handle_login_failed(request: Request, exec: InvalidCredentialsException):
    return JSONResponse(status_code=status.HTTP_403_FORBIDDEN,
                        content=repr(exec)
                        )

@app.exception_handler(InfoNotFoundException)
async def handle_info_not_found(request: Request, exec: InfoNotFoundException):
    return JSONResponse(status_code=status.HTTP_401_UNAUTHORIZED,
                        content=repr(exec)
                        )