Created
August 10, 2021 15:21
-
-
Save stilobique/3ddf91f57f4486e32ab64a7c05996bfd to your computer and use it in GitHub Desktop.
Setup a dedicated exception
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ErrorTest(Exception): | |
| """ A message about one error""" | |
| pass | |
| class ExceptTest(Exception): | |
| """ A message about one error""" | |
| pass | |
| def simple_func(value): | |
| try: | |
| if value == 0: | |
| raise ExceptTest | |
| elif value == 1: | |
| raise ErrorTest | |
| else: | |
| return True | |
| except (ExceptTest, ErrorTest) as exception: | |
| print(f'Error message : {exception.__doc__}') | |
| return {'ERROR'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment