Proper way to handle logging of exceptions
This commit is contained in:
parent
34dbffac9f
commit
df82337f1f
5
main.py
5
main.py
|
@ -122,5 +122,6 @@ try:
|
|||
# Wanna get a pretty JSON encoded library to do your nasty things offline at home? ;-)
|
||||
print(json.dumps(result, indent=4))
|
||||
|
||||
except:
|
||||
logging.error("Unexpected error:", sys.exc_info()[0])
|
||||
# Avoid printing on str{out,err} the unexpected exception traces. Log it instead.
|
||||
except Exception as e:
|
||||
logging.exception(e)
|
||||
|
|
Loading…
Reference in New Issue