learning123
"(FunctionClauseError) no function clause matching" error
Hey all, I’m new to elixir and getting the following error:
** (FunctionClauseError) no function clause matching in TSS.DriverStatuses.list_assignable_drivers_by_truck_load/1
So in my module, I define a get_remaining_time function that takes a truck_load:
defp get_remaining_time(truck_load) do
time_since_available = DriverStatuses.list_assignable_drivers_by_truck_load(truck_load)
Formatters.decorate_time_since_available(time_since_available)
end
This function uses the list_assignable_drivers_by_truck_load in the DriverStatuses module, which looks like this:
def list_assignable_drivers_by_truck_load(%TruckLoad{
well: %{id: well_id},
pull_point: pull_point
}) do
base_assignable_drivers_query()
|> apply_default_select(pull_point.point)
|> filter({:well_id, well_id})
|> sort({:distance_in_meters, :asc}, %{"pull_point_id" => pull_point.id})
|> preload(driver: [:trailer_type, driver_contract: [:carrier]])
|> Repo.all()
end
and then formats it using the decorate_time_since_available function in the Formatters module, which looks like this:
def decorate_time_since_available(%{driver_status: %{last_available_at: last_available_at}})
when not is_nil(last_available_at),
do:
humanize_time(DateTime.diff(DateTime.utc_now(), last_available_at), :seconds, :minutes) <>
" (hh:mm)"
def decorate_time_since_available(_), do: "N/A"
Finally, I am calling the function like so:
<CardInfo label="Time Since Available" title={{ get_remaining_time(@truck_load) }} small />
I think I’m not pattern matching correctly, but nothing I’ve tried is working. How can I fix this?
Thanks so much!!
Most Liked
derek-zhou
So your @truck_load is not a %TruckLoad(...} then. the error message after the ** (FunctionClausError)... line should give you more clue
Last Post!
AstonJ
2 posts were split to a new topic: FunctionClauseError on running mix rustler.new (no function clause matching in OptionParser.validate_swit)
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









