Last active
October 5, 2018 22:36
-
-
Save vladimirmyshkovski/64e66fbb97fde0ea5693c5d215e346c8 to your computer and use it in GitHub Desktop.
Custom 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 BaseCustomerError(Exception): | |
"""Basic error for all Customer errors.""" | |
pass | |
class CreateNewStepError(BaseCustomerError): | |
"""Exception raised when trying to create a new CustomerStep. | |
Attributes: | |
message -- explanation of the error | |
code -- code of the error | |
customer -- customer of the current CustomerStep instance | |
step -- current step of the CustomerStep instance | |
""" | |
def __init__(self, message, customer, step): | |
super(CreateNewStepError, self).__init__(message, customer, step) | |
self.message = message | |
self.customer = customer | |
self.step = step | |
self.code = 1 | |
def __str__(self): | |
message = (f'It is not possible to create a new CustomerStep with' | |
'Step {self.step} and Customer {self.customer}') | |
return message |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment