This commit is contained in:
adii1823
2021-10-28 17:39:13 +05:30
parent b6eb3ef8a7
commit 32c12d89f4
11 changed files with 301 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
# exceptions/replace.py
# This is not a valid Python module - Don't run it.
>>> class NotFoundError(Exception):
... pass
...
>>> vowels = {'a': 1, 'e': 5, 'i': 9, 'o': 15, 'u': 21}
>>> try:
... pos = vowels['y']
... except KeyError as e:
... raise NotFoundError(*e.args)
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
KeyError: 'y'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
__main__.NotFoundError: y
>>> try:
... pos = vowels['y']
... except KeyError as e:
... raise NotFoundError(*e.args) from e
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
KeyError: 'y'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
__main__.NotFoundError: y