-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Raise error when no entites requested
- Loading branch information
1 parent
d616273
commit 0b45681
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"""Contains preconditions that are applied to the handlers.""" | ||
from link.domain.commands import BatchCommand | ||
|
||
|
||
class NoEntitiesRequested(Exception): | ||
"""This exception is raised when a batch command that requests no entities is encountered.""" | ||
|
||
def __init__(self, command: BatchCommand) -> None: | ||
"""Initialize the exception.""" | ||
self.command = command | ||
|
||
|
||
def requests_entities(command: BatchCommand) -> None: | ||
"""Raise an exception if the given command requests no entities.""" | ||
if not command.requested: | ||
raise NoEntitiesRequested(command) |
This file contains 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
This file contains 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