diff --git a/README.md b/README.md index d212b93..9c1a561 100644 --- a/README.md +++ b/README.md @@ -1372,6 +1372,7 @@ except (, ...): except (, ...) as : ``` * **Also catches subclasses of the exception.** +* **Use `'traceback.print_exc()'` to print the the error message.** ### Raising Exceptions ```python @@ -1390,11 +1391,11 @@ except as : ### Exception Object ```python arguments = .args -line_number = .__traceback__.tb_lineno -func_name = .__traceback__.tb_frame.f_code.co_name +exc_type = .__class__ filename = .__traceback__.tb_frame.f_code.co_filename -line = linecache.getline(filename, line_num) -error_msg = traceback.format_exc() +func_name = .__traceback__.tb_frame.f_code.co_name +line = linecache.getline(filename, .__traceback__.tb_lineno) +error_msg = traceback.format_exception(exc_type, , .__traceback__) ``` ### Built-in Exceptions diff --git a/index.html b/index.html index b046a2b..d3e4174 100644 --- a/index.html +++ b/index.html @@ -1294,6 +1294,7 @@ LogicOp = Enum('LogicOp', {'traceback.print_exc()' to print the the error message.

Raising Exceptions

raise <exception>
 raise <exception>()
@@ -1306,11 +1307,11 @@ LogicOp = Enum('LogicOp', {Exception Object
arguments   = <name>.args
-line_number = <name>.__traceback__.tb_lineno
-func_name   = <name>.__traceback__.tb_frame.f_code.co_name
+exc_type    = <name>.__class__
 filename    = <name>.__traceback__.tb_frame.f_code.co_filename
-line        = linecache.getline(filename, line_num)
-error_msg   = traceback.format_exc()
+func_name   = <name>.__traceback__.tb_frame.f_code.co_name
+line        = linecache.getline(filename, <name>.__traceback__.tb_lineno)
+error_msg   = traceback.format_exception(exc_type, <name>, <name>.__traceback__)
 

Built-in Exceptions

BaseException