我想要做的是mochijson2:decode(Ccode)
生成任何异常或错误,程序执行不应该停止并且应该执行case branch {error,Reason}。Erlang中的异常处理继续执行
但是,当我试图让它实现时,它会在第一行生成错误,而检查并且代码不会继续执行下面的行。
SCustomid = case mochijson2:decode(Ccode) of
{struct, JsonDataa} ->
{struct, JsonData} = mochijson2:decode(Ccode),
Mvalll = proplists:get_value(<<"customid">>, JsonData),
Pcustomid = erlang:binary_to_list(Mvalll),
"'" ++ Pcustomid ++ "'";
{error, Reason} -> escape_str(LServer, Msg#archive_message.customid)
end,
你可以建议,如果我需要使用Try Catch。我对Ejabberd有点经验,但对Erlang来说是新手。任何帮助表示赞赏。
作品完美 –