Why am I getting this error for Changeset.add_error/4?

I am trying to add a custom error if certain criteria is met, but I am keep getting this error when I am calling add_error/4
this is what the logs show:

** (FunctionClauseError) no function clause matching in Ecto.Changeset.add_error/4
(ecto) lib/ecto/changeset.ex:1535: Ecto.Changeset.add_error(%XD.BusinessAccounts.UserBusinessAccount
{__meta__: #Ecto.Schema.Metadata<:loaded, "user_business_accounts">, business_account:
 #Ecto.Association.NotLoaded<association :business_account is not loaded>, business_account_id: 4, 
deleted_at: nil, id: 23, inserted_at: #DateTime<2019-02-22 07:53:49Z>, role: "admin", status: "added",
 updated_at: #DateTime<2019-02-22 07:55:52Z>, user: #Ecto.Association.NotLoaded<association :user is 
not loaded>, user_id: 3}, :business_account, "User is already an admin", [])
(XD) lib/XD/business_accounts/business_accounts.ex:110: anonymous fn/3 in 

Why is it not matching? to me it looks like it has 4 arguments

You need to pass a changeset, not a record.

4 Likes