Link to home
Start Free TrialLog in
Avatar of Mehan CO
Mehan COFlag for United States of America

asked on

find the error code given by python and then put it in the except case

i want know how do it ? is it possible write it to file and i look at it later ?
ASKER CERTIFIED SOLUTION
Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Some more comments:

Above solution will always log an error and an exception if you stop your program with ctrl-C or if you kill it.
If that's an issue, then you can specifically exclude KeyboardInterrupt and SystemExit

Above solution has also solutions with multithreaded applications.
Exceptions in a thread will unfortunately not be caught by sys.excepthook

However there are some potential tricks / hacks, which might help you in such cases