2023-04-22 16:33:28 +12:00
|
|
|
defmodule AshStateMachine.Errors.NoMatchingTransition do
|
|
|
|
@moduledoc "Used when a state change occurs in an action with no matching transition"
|
2024-03-30 11:01:07 +13:00
|
|
|
use Splode.Error,
|
|
|
|
fields: [:action, :target, :old_state],
|
|
|
|
class: :invalid
|
|
|
|
|
|
|
|
def message(error) do
|
2024-05-02 01:15:40 +12:00
|
|
|
cond do
|
|
|
|
error.old_state && error.target ->
|
|
|
|
"""
|
|
|
|
Attempted to change state from #{error.old_state} to #{error.target} in action #{error.action}, but no matching transition was configured.
|
|
|
|
"""
|
|
|
|
|
|
|
|
error.old_state ->
|
|
|
|
"""
|
|
|
|
Attempted to change state from #{error.old_state} in action #{error.action}, but no matching transition was configured.
|
|
|
|
"""
|
|
|
|
|
|
|
|
error.target ->
|
|
|
|
"""
|
|
|
|
Attempted to change state to #{error.target} in action #{error.action}, but no matching transition was configured.
|
|
|
|
"""
|
2024-04-17 13:32:42 +12:00
|
|
|
end
|
2023-04-22 07:25:39 +12:00
|
|
|
end
|
|
|
|
end
|