python custom errors
class MyException(Exception):
"""You can put code here"""
pass
class MyOtherException(MyException):
"""You can also put code here"""
pass
python custom errors
class MyException(Exception):
"""You can put code here"""
pass
class MyOtherException(MyException):
"""You can also put code here"""
pass
except as Exception:
>>> def catch():
... try:
... asd()
... except Exception as e:
... print e.message, e.args
...
>>> catch()
global name 'asd' is not defined ("global name 'asd' is not defined",)
python custom errors
>>> class CustomError(Exception):
... pass
...
>>> raise CustomError
Traceback (most recent call last):
...
__main__.CustomError
>>> raise CustomError("An error occurred")
Traceback (most recent call last):
...
__main__.CustomError: An error occurred
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us