如何在erlang中格式化throw语句

如何在erlang中格式化throw语句,erlang,Erlang,我不熟悉Erlang语法,正在努力解决这个问题 我可以这样做并编译 throw(Reason) 属于类型throw/1 我希望能够做到这一点: %% I have seen this code in sample examples. ?THROW("Couldn't start process: ~p. ~n", [Reason]) 我不认为有throw/2。 那么我如何定义像上面这样的宏呢??THROW是一个宏。应将其定义为: -define(THROW(Format,Params),

我不熟悉Erlang语法,正在努力解决这个问题

我可以这样做并编译

  throw(Reason)
属于类型
throw/1

我希望能够做到这一点:

%% I have seen this code in sample examples.
?THROW("Couldn't start process: ~p. ~n", [Reason])
我不认为有
throw/2。


那么我如何定义像上面这样的宏呢?

?THROW是一个宏。应将其定义为:

-define(THROW(Format,Params),throw(io_lib:format(Format,Params))).
在此定义中,对
io_lib:format(format,Params)
的调用返回一个字符串,该字符串被函数throw用作原因