Skip to content

Instantly share code, notes, and snippets.

@vladimirmyshkovski
Last active October 5, 2018 22:36
Show Gist options
  • Save vladimirmyshkovski/64e66fbb97fde0ea5693c5d215e346c8 to your computer and use it in GitHub Desktop.
Save vladimirmyshkovski/64e66fbb97fde0ea5693c5d215e346c8 to your computer and use it in GitHub Desktop.
Custom exception
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