Ecto Changeset Error

I’m getting the following exception for a failed changeset:

Process #PID<0.9321.1> raised an exception
** (MatchError) no match of right hand side value: {:error, #Ecto.Changeset<action: :update, changes: %{}, errors: [title: {"can't be blank", []}], data: #SlackCoder.Models.PR<>, valid?: false>}
    (slack_coder) lib/slack_coder/github/helper.ex:188: SlackCoder.Github.Helper.build_pr/2
    (slack_coder) lib/slack_coder/github/helper.ex:96: SlackCoder.Github.Helper._status/1
    (slack_coder) lib/slack_coder/github/helper.ex:86: anonymous fn/2 in SlackCoder.Github.Helper.status/1

What I’d like to know is more information about the schema data that failed validation. But I see here that it is hard coded not to display any information about the model:
https://github.com/elixir-lang/ecto/blob/master/lib/ecto/changeset.ex#L1861

If an Ecto.Schema had a default implementation for the inspect protocol just to display all the data, that line could instead just call inspect on the data and it would produce a more informative error message.

Is there any reason why this isn’t already the case?

2 Likes

@mgwidmann I think slightly better place to ask this sort of implementation question would be https://groups.google.com/forum/#!forum/elixir-ecto where Ecto maintainers hang out more often :wink:

1 Like