Reputation: 21
I keep getting an exception error while debugging an Erlang chat engine.
The error message reads:
exception error: no function clause matching code_lock:locked(cast,
{button,1}, #{button => [], code => [a,b,c,d], length => 4})
Any idea how to debug that?
Upvotes: 1
Views: 172
Reputation: 21
Ok this had to do with the parameters to match the existing definition. Sorted it and the debugging process is ok.
Upvotes: 0
Reputation: 241868
The function locked
is defined (the exception should also tell you in which while and on what line its definition starts), but none of the clauses matches the parameters shown in the exception.
For example, if we define
nfcm([H|T],X) ->
[H,X|T];
nfcm({A,B},C) ->
{A,C,B}.
We can call nfcm([1,2,3], 4)
and nfcm({1,2}, 3)
to get [1,4,2,3]
and {1,3,2}
, but calling nfcm(1, 2)
or nfcm({1,2,3}, 4)
leads to the exception, as 1
doesn't match neither a list nor a tuple, and {1,2,3}
doesn't match a list either, and doesn't match a tuple of two elements.
There are two ways to solve the problem: either fix the definition of the function, or fix the parameters to match the existing definition.
Upvotes: 1