mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-11-15 11:14:28 +00:00
Fix exception logging
This commit is contained in:
parent
fcf7b9f939
commit
ce4ff0b92e
1 changed files with 7 additions and 2 deletions
9
app.py
9
app.py
|
@ -3,6 +3,7 @@ import json
|
||||||
import logging
|
import logging
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
|
import traceback
|
||||||
import urllib
|
import urllib
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from datetime import timezone
|
from datetime import timezone
|
||||||
|
@ -404,7 +405,9 @@ def is_api_request():
|
||||||
|
|
||||||
@app.errorhandler(ValueError)
|
@app.errorhandler(ValueError)
|
||||||
def handle_value_error(error):
|
def handle_value_error(error):
|
||||||
logger.error(f"caught value error: {error!r}, {error.__traceback__!r}")
|
logger.error(
|
||||||
|
f"caught value error: {error!r}, {traceback.format_tb(error.__traceback__)}"
|
||||||
|
)
|
||||||
response = flask_jsonify(message=error.args[0])
|
response = flask_jsonify(message=error.args[0])
|
||||||
response.status_code = 400
|
response.status_code = 400
|
||||||
return response
|
return response
|
||||||
|
@ -412,7 +415,9 @@ def handle_value_error(error):
|
||||||
|
|
||||||
@app.errorhandler(Error)
|
@app.errorhandler(Error)
|
||||||
def handle_activitypub_error(error):
|
def handle_activitypub_error(error):
|
||||||
logger.error(f"caught activitypub error {error!r}, {error.__traceback__!r}")
|
logger.error(
|
||||||
|
f"caught activitypub error {error!r}, {traceback.format_tb(error.__traceback__)}"
|
||||||
|
)
|
||||||
response = flask_jsonify(error.to_dict())
|
response = flask_jsonify(error.to_dict())
|
||||||
response.status_code = error.status_code
|
response.status_code = error.status_code
|
||||||
return response
|
return response
|
||||||
|
|
Loading…
Reference in a new issue