From a97d71ba8d8a06d5eabd615f0a662e3495b82403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Thu, 13 Feb 2020 12:46:12 +0100 Subject: [PATCH] Exceptions --- README.md | 16 ++++++++-------- index.html | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 8c4cd29..d87a779 100644 --- a/README.md +++ b/README.md @@ -1396,7 +1396,7 @@ line = linecache.getline(filename, line_num) error_msg = traceback.format_exc() ``` -### Common Built-in Exceptions +### Built-in Exceptions ```text BaseException +-- SystemExit # Raised by the sys.exit() function. @@ -1420,13 +1420,6 @@ BaseException +-- UnicodeError # Raised when encoding/decoding strings from/to bytes fails. ``` -#### Useful built-in exceptions: -```python -raise TypeError('Argument is of wrong type!') -raise ValueError('Argument is of right type but inappropriate value!') -raise RuntimeError('None of above!') -``` - #### Collections and their exceptions: ```text +-----------+------------+------------+------------+ @@ -1439,6 +1432,13 @@ raise RuntimeError('None of above!') +-----------+------------+------------+------------+ ``` +#### Useful built-in exceptions: +```python +raise TypeError('Argument is of wrong type!') +raise ValueError('Argument is of right type but inappropriate value!') +raise RuntimeError('None of above!') +``` + ### User-defined Exceptions ```python class MyError(Exception): diff --git a/index.html b/index.html index dad9f8c..cb1682b 100644 --- a/index.html +++ b/index.html @@ -1310,7 +1310,7 @@ line = linecache.getline(filename, line_num) error_msg = traceback.format_exc() -

Common Built-in Exceptions

BaseException
+

Built-in Exceptions

BaseException
  +-- SystemExit                   # Raised by the sys.exit() function.
  +-- KeyboardInterrupt            # Raised when the user hits the interrupt key (ctrl-c).
  +-- Exception                    # User-defined exceptions should be derived from this class.
@@ -1332,11 +1332,6 @@ error_msg = traceback.format_exc()
            +-- UnicodeError       # Raised when encoding/decoding strings from/to bytes fails.
 
-

Useful built-in exceptions:

raise TypeError('Argument is of wrong type!')
-raise ValueError('Argument is of right type but inappropriate value!')
-raise RuntimeError('None of above!')
-
-

Collections and their exceptions:

+-----------+------------+------------+------------+
 |           |    list    |    dict    |    set     |
 +-----------+------------+------------+------------+
@@ -1347,6 +1342,11 @@ error_msg = traceback.format_exc()
 +-----------+------------+------------+------------+
 
+

Useful built-in exceptions:

raise TypeError('Argument is of wrong type!')
+raise ValueError('Argument is of right type but inappropriate value!')
+raise RuntimeError('None of above!')
+
+

User-defined Exceptions

class MyError(Exception):
     pass