How to create a custom exception?
Answer
•Inherit from Exception: class MyError(Exception): pass.
•Use a meaningful name.
•Pass a message: raise MyError('...').
•For parameters — store them in attributes.
•Do not inherit from BaseException.
Was this answer helpful?