I have one questions, which related to decorators. for example I wrote the next decorator, which handle the error, and then just output the error.
def handle_error(func):
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except Exception as err:
print(err)
return wrapper
@handle_error
def raise_error():
return 1 / 0
raise_error()
But, if I want to do the same with Flask it's doesn't work.
@app.route('/')
@handle_error
def index():
return {'hello'}
if __name__ == '__main__':
app.run()
So I'm guessing, the error raised in route decorator, am I right? if yes, I have question: Technically I can to write an decorator which will be handle all exceptions from route decorator?