benonymus

benonymus

(FunctionClauseError) - why I am getting this or how to fix it?

So the erro meassage is :

(exit) an exception was raised:
    ** (FunctionClauseError) no function clause matching in MyApiWeb.FallbackController.call/2

And the code where it is coming from is :

def create(conn, %{
  "description" => description,
  "email" => email,
  "source" => source,
  "subscriptionID" => subscriptionID
}) do
  with {:ok, %t{} = t} <- Stripe.Customer.create(%{description: description, email: email}) do
    conn
    |> IO.inspect(t)
  end
end

Thanks

Marked As Solved

idi527

idi527

The original error says that no function head in MyApiWeb.FallbackController matches what’s returned from your create controller action. MyApiWeb.FallbackController, judging by your code snippet, can match either {:error, %Ecto.Changeset{} = changeset} or {:error, :not_found}, and nothing else. So if it receives, for example, %Stripe.User{}, it just doesn’t know what to do with it. You can add a new function which would match what’s returned from the create action and the error would disappear, but I doubt that’s what you actually want. I think the real problem is with the pattern in your with statement, {:ok, %t{} = t}.

Also I tried what khm idiot suggested and with that for the first try it went throug nicely but for the second one got the stripe user printed out and got the same fallback error

:+1:

But printed out where? If you mean IO.inspect, then for which label, unmatched? If so, then that’s your solution right there – fix your pattern in with to match on a stripe user so that it doesn’t fail.

Last Post!

benonymus

benonymus

Thank you

Where Next?

Popular in Questions Top

New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42716 114
New

We're in Beta

About us Mission Statement