Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python exception with line number

try:
    raise NotImplementedError("Not implemented")
except Exception as e:
    exception_type, exception_object, exception_traceback = sys.exc_info()
    filename = exception_traceback.tb_frame.f_code.co_filename
    line_number = exception_traceback.tb_lineno

    print("Exception type: ", exception_type)
    print("File name: ", filename)
    print("Line number: ", line_number)
Source by www.kite.com #
 
PREVIOUS NEXT
Tagged: #python #exception #line #number
ADD COMMENT
Topic
Name
4+9 =