Projekt

Obecné

Profil

Stáhnout (973 Bajtů) Statistiky
| Větev: | Tag: | Revize:
1
from src.controllers.return_codes import C_INTERNAL_SERVER_ERROR
2
from src.utils.logger import Logger
3

    
4
E_UNHANDLED_CRYPTOGRAPHY_ERROR = {"success": False,
5
                                  "data": "An unknown error has happened in the cryptography library."}
6
E_UNHANDLED_DATABASE_ERROR = {"success": False, "data": "An unknown database error has happened."}
7
E_UNHANDLED_ERROR = {"success": False, "data": "An unknown error has happened."}
8

    
9

    
10
def handle_cryptography_exception(e):
11
    Logger.error(f"An unhandled CryptographyException has been raised: {str(e)}")
12
    return E_UNHANDLED_CRYPTOGRAPHY_ERROR, C_INTERNAL_SERVER_ERROR
13

    
14

    
15
def handle_database_exception(e):
16
    Logger.error(f"An unhandled DatabaseException has been raised: {str(e)}")
17
    return E_UNHANDLED_DATABASE_ERROR, C_INTERNAL_SERVER_ERROR
18

    
19

    
20
def handle_generic_exception(e):
21
    Logger.error(f"An unknown Exception ({type(e)}) has been raised: {str(e)}")
22
    return E_UNHANDLED_ERROR, C_INTERNAL_SERVER_ERROR
(4-4/5)