Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider handle_x to use Ecto.InvalidChangesetError for errors #61

Open
joshuataylor opened this issue May 30, 2017 · 1 comment
Open

Comments

@joshuataylor
Copy link
Contributor

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 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
@psteininger
Copy link
Collaborator

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants