From 5c6d06f541ade69e4d0e32cdd844b4be83b4fe63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Fri, 17 Jun 2022 02:52:17 +0200 Subject: [PATCH] Exceptions --- README.md | 8 +++----- index.html | 12 +++++------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 3a79b33..bbcae2e 100644 --- a/README.md +++ b/README.md @@ -1428,6 +1428,7 @@ exc_type = .__class__ filename = .__traceback__.tb_frame.f_code.co_filename func_name = .__traceback__.tb_frame.f_code.co_name line = linecache.getline(filename, .__traceback__.tb_lineno) +traceback = ''.join(traceback.format_tb(.__traceback__)) error_msg = ''.join(traceback.format_exception(exc_type, , .__traceback__)) ``` @@ -1476,11 +1477,8 @@ raise RuntimeError('None of above!') ### User-defined Exceptions ```python -class MyError(Exception): - pass - -class MyInputError(MyError): - pass +class MyError(Exception): pass +class MyInputError(MyError): pass ``` diff --git a/index.html b/index.html index 940dd5f..360a2d9 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -1226,6 +1226,7 @@ exc_type = <name>.__class__ filename = <name>.__traceback__.tb_frame.f_code.co_filename func_name = <name>.__traceback__.tb_frame.f_code.co_name line = linecache.getline(filename, <name>.__traceback__.tb_lineno) +traceback = ''.join(traceback.format_tb(<name>.__traceback__)) error_msg = ''.join(traceback.format_exception(exc_type, <name>, <name>.__traceback__)) @@ -1266,11 +1267,8 @@ error_msg = ''.join(traceback.format_exception( raise RuntimeError('None of above!') -

User-defined Exceptions

class MyError(Exception):
-    pass
-
-class MyInputError(MyError):
-    pass
+

User-defined Exceptions

class MyError(Exception): pass
+class MyInputError(MyError): pass
 

#Exit

Exits the interpreter by raising SystemExit exception.

import sys
@@ -2902,7 +2900,7 @@ $ pyinstaller script.py --add-data '<path>:.'