ja_resource
ja_resource copied to clipboard
Consider handle_x to use Ecto.InvalidChangesetError for errors
So when a changeset is invalid, Ecto returns an Ecto.InvalidChangesetError
. This is what should be used instead of @type validation_errors :: {:error, Ecto.Changeset.t}
, as otherwise you have to do changeset.changeset
, like as follows:
def handle_create(_conn, attributes) do
try do
post = Post.create(attributes)
{:ok, post} = post
rescue
changeset in [Ecto.InvalidChangesetError] -> {:error, changeset.changeset}
end
end
@joshuataylor could you provide more details? I have taken over maintenance of the project. This issue is almost 3 years old, and not sure how to bite into it. Thanks in advance.