Created
January 6, 2020 21:35
-
-
Save StephenFordham/8ea287187a0fde02a8ee82d5a1f2039f to your computer and use it in GitHub Desktop.
MyCustomError
This file contains 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 MyCustomError(Exception): | |
def __init__(self, *args): | |
if args: | |
self.message = args[0] | |
else: | |
self.message = None | |
def __str__(self): | |
print('calling str') | |
if self.message: | |
return 'MyCustomError, {0} '.format(self.message) | |
else: | |
return 'MyCustomError has been raised' | |
# raise MyCustomError | |
raise MyCustomError('We have a problem') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice help thx!