Skip to content

Commit

Permalink
Improve custom exception example
Browse files Browse the repository at this point in the history
  • Loading branch information
quiqueporta committed May 24, 2024
1 parent 2ef7873 commit 476c5a0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class Point(ValueObject):
x: int
y: int

@invariant(MyException)
@invariant(exception_type=MyException)
def inside_first_quadrant(self):
return self.x > 0 and self.y > 0, "You must be inside the first quadrant"

Expand Down
4 changes: 2 additions & 2 deletions specs/value_object_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class Foo(ValueObject):

@invariant(exception_type=MyCustomException)
def bar(self):
return False
return self.any == "foo"

expect(lambda: Foo("buzz")).to(raise_error(MyCustomException))

Expand All @@ -279,7 +279,7 @@ class Foo(ValueObject):

@invariant(exception_type=MyCustomException)
def bar(self):
return False, "This is a custom message"
return self.any == "foo", "This is a custom message"

expect(lambda: Foo("buzz")).to(
raise_error(MyCustomException, "This is a custom message")
Expand Down

0 comments on commit 476c5a0

Please sign in to comment.