You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
joshuataylor
changed the title
Considering handle_x to use Ecto.InvalidChangesetError for errors
Consider handle_x to use Ecto.InvalidChangesetError for errors
Jun 12, 2017
@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.
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 dochangeset.changeset
, like as follows:The text was updated successfully, but these errors were encountered: