Thrift/Erlang string

erlang, thrift

Solution

That last argument of apply should be a list of arguments to 'test', e.g., if tuple_to_list(Args) resulted in:

[1]

...then:

test(1)

If `tuple_to_list(Args)` resulted in:

[1,2]

...then:

test(1,2)

So, if `{<<"woot">>}` is being passed to `tuple_to_list`, that's going to be:

[<<"woot">>]

...so:

test(<<"woot">>)

...but test's signature asks for a list as the argument, so there's a mismatch.

Problem

I'm trying to write a simple Thrift server in Erlang that takes a string and returns a string. Everything seems to be working up to the point of calling my function: ``` handle_function(Function, Args) when is_atom(Function), is_tuple(Args) -> case apply(?MODULE, Function, tuple_to_list(Args)) of ok -> ok; Reply -> {reply, Reply} end. test([X]) -> "You sent: " ++ X. ``` I'm getting a function_clause. The stack trace shows the following: {function_clause, [{server, test, [<<"w00t">>]}, {server,handle_function, 2}, ... My handle_function is copied from the tutorial file so I won't be surprised if I need to tweak it. Any ideas?

Original source