mirror of
https://github.com/ash-project/ash.git
synced 2024-09-19 21:13:10 +12:00
improvement: better error messages on incorrect action types
This commit is contained in:
parent
b999fb10ab
commit
d6a973cef0
2 changed files with 14 additions and 2 deletions
|
@ -1251,6 +1251,19 @@ defmodule Ash.Changeset do
|
||||||
other -> other
|
other -> other
|
||||||
end
|
end
|
||||||
|
|
||||||
|
case action do
|
||||||
|
%Ash.Resource.Actions.Update{name: name} ->
|
||||||
|
raise ArgumentError,
|
||||||
|
message: """
|
||||||
|
Action #{inspect(changeset.resource)}.#{name} was passed to `Ash.Changeset.for_create`, but it is an update action.
|
||||||
|
|
||||||
|
Perhaps you meant to call `Ash.Changeset.for_create` instead?
|
||||||
|
"""
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
:ok
|
||||||
|
end
|
||||||
|
|
||||||
changeset
|
changeset
|
||||||
|> set_context(%{
|
|> set_context(%{
|
||||||
private: %{
|
private: %{
|
||||||
|
|
|
@ -709,7 +709,6 @@ defmodule Ash.Test.Actions.LoadTest do
|
||||||
|> Ash.Query.load([:posts, :latest_post])
|
|> Ash.Query.load([:posts, :latest_post])
|
||||||
|> Ash.read!(authorize?: true)
|
|> Ash.read!(authorize?: true)
|
||||||
|
|
||||||
author =
|
|
||||||
Ash.load!(author, [:posts, :latest_post], lazy?: true)
|
Ash.load!(author, [:posts, :latest_post], lazy?: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue