Revize 266e1b4d
Přidáno uživatelem Stanislav Král před téměř 4 roky(ů)
app.py | ||
---|---|---|
10 | 10 |
from src.config.connection_provider import ConnectionProvider |
11 | 11 |
from src.controllers.certificates_controller import CertController |
12 | 12 |
from src.controllers.crl_ocsp_controller import CrlOcspController |
13 |
from src.controllers.exception_handlers import handle_cryptography_exception, handle_database_exception, \ |
|
14 |
handle_generic_exception |
|
13 | 15 |
from src.exceptions.database_exception import DatabaseException |
14 | 16 |
from src.services.cryptography import CryptographyService, CryptographyException |
15 | 17 |
from src.utils.logger import Logger |
... | ... | |
93 | 95 |
|
94 | 96 |
|
95 | 97 |
@app.errorhandler(CryptographyException) |
96 |
def cryptography_error(e, certificate_controller: CertController):
|
|
97 |
return certificate_controller.handle_cryptography_error(e)
|
|
98 |
def cryptography_error(e): |
|
99 |
return handle_cryptography_exception(e)
|
|
98 | 100 |
|
99 | 101 |
|
100 | 102 |
@app.errorhandler(DatabaseException) |
101 |
def database_error(e, certificate_controller: CertController):
|
|
102 |
return certificate_controller.handle_database_error(e)
|
|
103 |
def database_error(e): |
|
104 |
return handle_database_exception(e)
|
|
103 | 105 |
|
104 | 106 |
|
105 | 107 |
@app.errorhandler(Exception) |
106 |
def generic_exception(e, certificate_controller: CertController):
|
|
108 |
def generic_exception(e): |
|
107 | 109 |
if isinstance(e, HTTPException): |
110 |
# handle HTTPException exceptions here (MethodNotAllowed for example) |
|
108 | 111 |
Logger.warning(f""" HTTPException occurred: "{str(e)}" """) |
109 | 112 |
return str(e), e.code |
110 |
return certificate_controller.handle_generic_exception(e)
|
|
113 |
return handle_generic_exception(e) |
|
111 | 114 |
|
112 | 115 |
|
113 | 116 |
def initialize_app(application) -> bool: |
Také k dispozici: Unified diff
Moved global error handlers out of the CertificateController to a separate file.
Renamed generic exception handlers.