Skip to content

Commit

Permalink
Create a base exception to make capture errors easier
Browse files Browse the repository at this point in the history
  • Loading branch information
quiqueporta committed Oct 27, 2022
1 parent 43b6c87 commit d6fd61f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions simple_value_object/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
class ConstructorWithoutArguments(Exception):
class SimpleValueObjectException(Exception):
pass


class ConstructorWithoutArguments(SimpleValueObjectException):
def __init__(self):
super().__init__('No arguments declared in __init__')


class CannotBeChanged(Exception):
class CannotBeChanged(SimpleValueObjectException):
def __init__(self):
super().__init__(
'You cannot change values from a Value Object, create a new one'
)


class InvariantViolation(Exception):
class InvariantViolation(SimpleValueObjectException):
pass


class InvariantMustReturnBool(Exception):
class InvariantMustReturnBool(SimpleValueObjectException):
def __init__(self):
super().__init__('Invariants must return a boolean value')

0 comments on commit d6fd61f

Please sign in to comment.