Revize d55b3aff
Přidáno uživatelem Stanislav Král před téměř 4 roky(ů)
app.py | ||
---|---|---|
1 | 1 |
import os |
2 | 2 |
|
3 | 3 |
from flask import Flask, redirect, request |
4 |
from injector import Injector |
|
5 | 4 |
from flask_injector import FlaskInjector |
5 |
from injector import Injector |
|
6 |
from werkzeug.exceptions import HTTPException |
|
6 | 7 |
|
7 | 8 |
from src.config import configuration |
8 | 9 |
from src.config.configuration import Configuration |
... | ... | |
101 | 102 |
return certificate_controller.handle_database_error(e) |
102 | 103 |
|
103 | 104 |
|
105 |
@app.errorhandler(Exception) |
|
106 |
def generic_exception(e, certificate_controller: CertController): |
|
107 |
if isinstance(e, HTTPException): |
|
108 |
Logger.warning(f""" HTTPException occurred: "{str(e)}" """) |
|
109 |
return str(e), e.code |
|
110 |
return certificate_controller.handle_generic_exception(e) |
|
111 |
|
|
112 |
|
|
104 | 113 |
def initialize_app(application) -> bool: |
105 | 114 |
""" |
106 | 115 |
Initializes the application |
Také k dispozici: Unified diff
Added a global error handler for generic exceptions.
Covered the added global exception error handler in a test.