Often you need to disable try/except blocks while debugging code because you want to find out the point of occurrence of the exception and other info which is swallowed by the block that catches the exception. With languages that use braces for block demarcation, it's as easy as simply commenting out the try and catch/except lines, minding the
(
Read more... )
Comments 1
import traceback
try:
some_code
some_more_code
except:
some_code
print traceback.format_exc()
The last line in the code will print the traceback to the exception. The advantage of using traceback is that exceptions can be logged in prod/dev. enviornment. Comment the line, when the details of exceptions are not required.
Regards,
Mohit Ranka
http://www.linkedin.com/in/mohitranka
Reply
Leave a comment