Page 1 of 1

Catch all exceptions, what exception was raised?

Posted: Sun Mar 19, 2017 4:29 pm
by Khyrtsi
If I catch all exceptions, how can I see what exception was raised?

I know that it's normally considered bad practise to catch all, but I would like to log the exception to somewhere (network or lcd) and not just freeze.

Re: Catch all exceptions, what exception was raised?

Posted: Sun Mar 19, 2017 4:38 pm
by pythoncoder

Code: Select all

paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== try:
===     1/0
=== except Exception as e:
===     print(e)
=== 
division by zero
>>>