Skip to content

Commit

Permalink
Improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
danpalmer committed Jan 15, 2018
1 parent d74e86a commit b7b310e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions routemaster/state_machine/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def process_action(
implies further progression should be attempted.
"""
if not isinstance(state, Action): # pragma: no branch
raise RuntimeError( # pragma: no cover
f"{state.name} is not an actio, but was passed to process_action",
raise ValueError( # pragma: no cover
f"process_action called with {state.name} which is not an Action",
)

action = state
Expand Down
4 changes: 2 additions & 2 deletions routemaster/state_machine/gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def process_gate(
implies further progression should be attempted.
"""
if not isinstance(state, Gate): # pragma: no branch
raise RuntimeError( # pragma: no cover
f"{state.name} is not a gate, but was passed to process_gate",
raise ValueError( # pragma: no cover
f"process_gate called with {state.name} which is not an Gate",
)

gate = state
Expand Down
5 changes: 3 additions & 2 deletions routemaster/state_machine/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ def labels_needing_metadata_update_retry_in_gate(
) -> List[str]:
"""Util to get all the labels in an action state that need retrying."""
if not isinstance(state, Gate): # pragma: no branch
raise RuntimeError( # pragma: no cover
f"{state.name} is not a gate, but was passed to process_gate",
raise ValueError( # pragma: no cover
f"labels_needing_metadata_update_retry_in_gate called with "
f"{state.name} which is not an Gate",
)

return _labels_in_state(
Expand Down

0 comments on commit b7b310e

Please sign in to comment.