How do I find what kind of exception is thrown.
Antoon Pardon wrote:
> Python 2.6.4 on a solaris box.
> I have a program in which all kind of excptions can be thrown and caugth.
> The main program is something like below:
> except Exception:
> log unexpected trouble
> Now I found the following in the logs: [Errno 131] Connection reset by
> This is a problem I would like to catch earlier however I have no idea
> what exception I would have to catch in order to treat this case.
The logging package in the stdlib provides a way to include the traceback
into the logfile:
$ cat log_exc.py
logger = logging.getLogger()
$ python3 log_exc.py
$ cat tmp.log
Traceback (most recent call last):
File "log_exc.py", line 10, in <module>
File "log_exc.py", line 4, in do_stuff
ZeroDivisionError: division by zero