Skip to content

Instantly share code, notes, and snippets.

@StephenFordham
Created January 6, 2020 21:35
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StephenFordham/8ea287187a0fde02a8ee82d5a1f2039f to your computer and use it in GitHub Desktop.
Save StephenFordham/8ea287187a0fde02a8ee82d5a1f2039f to your computer and use it in GitHub Desktop.
MyCustomError
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')
@enrialonso
Copy link

nice help thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment