diff --git a/lib/ash/api/api.ex b/lib/ash/api/api.ex index d2429c34..0358ef59 100644 --- a/lib/ash/api/api.ex +++ b/lib/ash/api/api.ex @@ -1075,7 +1075,7 @@ defmodule Ash.Api do end defp unwrap_or_raise!({:error, error}, stacktraces?, _) do - exception = Ash.Error.to_ash_error(error) + exception = Ash.Error.to_error_class(error) exception = if stacktraces? do diff --git a/test/actions/read_test.exs b/test/actions/read_test.exs index c3f00801..331af1e3 100644 --- a/test/actions/read_test.exs +++ b/test/actions/read_test.exs @@ -158,6 +158,15 @@ defmodule Ash.Test.Actions.ReadTest do assert ^post = clear_meta(Api.get!(Post, post.id)) end + test "it raises when there is no matching record" do + res = + assert_raise Ash.Error.Invalid, fn -> + Api.get!(Post, Ash.UUID.generate()) + end + + assert [%Ash.Error.Query.NotFound{}] = res.errors + end + test "raises an error when the first argument is not a module", %{post: post} do res = assert_raise Ash.Error.Invalid.NoSuchResource, fn -> Api.get("bogus", post.id, []) end assert res.message =~ ~r/Ash.Test.Actions.ReadTest.Api.get\/3/