0

riak データベースで顧客を更新しようとすると、次のエラー メッセージが表示されます。このエラーの原因と、このエラー メッセージの意味がわかりません。

そして、私が使用するモジュールは次のとおりです。

allowed_methods(Request, State) ->
    {['PUT'], Request, State}.

content_types_accepted(Request, State) ->
    {[{"application/json",to_json}], Request, State}.

エラー

キープアライブ"},nil,nil}, {"コンテンツ タイプ", {'コンテンツ タイプ',"アプリケーション/json; charset=UTF-8"}, nil, {"host", {'Host',"localhost:8000"}, {"expect",{"Expect","100-Continue"},nil,nil}, { "ユーザーエージェント", {'ユーザーエージェント',"Apache-HttpClient/4.0.1 (Java 1.5)"}, nil,nil}}}}}, not_fetched_yet,false, {1,{"コンテンツタイプ" ,{"Content-Type","text/html"},nil,nil}}, <<>>, ["localhost"], 8000,[]}, undefined]}, {webmachine_resource,resource_call,3}, {webmachine_resource,do,3}, {webmachine_decision_core,resource_call,1}, {webmachine_decision_core,accept_helper,0}, {webmachine_decision_core,decision,1}, {webmachine_decision_core,handle_request,2}, {webmachine_mochiweb,loop,1}]}} コンテンツ タイプ", {'コンテンツ タイプ',"アプリケーション/json; charset=UTF-8"}, nil, {"host", {'Host',"localhost:8000"}, {"expect",{"Expect","100-Continue"},nil,nil}, { "ユーザーエージェント", {'ユーザーエージェント',"Apache-HttpClient/4.0.1 (Java 1.5)"}, nil,nil}}}}}, not_fetched_yet,false, {1,{"コンテンツタイプ" ,{"Content-Type","text/html"},nil,nil}}, <<>>, ["localhost"], 8000,[]}, undefined]}, {webmachine_resource,resource_call,3}, {webmachine_resource,do,3}, {webmachine_decision_core,resource_call,1}, {webmachine_decision_core,accept_helper,0}, {webmachine_decision_core,decision,1}, {webmachine_decision_core,handle_request,2}, {webmachine_mochiweb,loop,1}]}} コンテンツ タイプ", {'コンテンツ タイプ',"アプリケーション/json; charset=UTF-8"}, nil, {"host", {'Host',"localhost:8000"}, {"expect",{"Expect","100-Continue"},nil,nil}, { "ユーザーエージェント", {'ユーザーエージェント',"Apache-HttpClient/4.0.1 (Java 1.5)"}, nil,nil}}}}}, not_fetched_yet,false, {1,{"コンテンツタイプ" ,{"Content-Type","text/html"},nil,nil}}, <<>>, ["localhost"], 8000,[]}, undefined]}, {webmachine_resource,resource_call,3}, {webmachine_resource,do,3}, {webmachine_decision_core,resource_call,1}, {webmachine_decision_core,accept_helper,0}, {webmachine_decision_core,decision,1}, {webmachine_decision_core,handle_request,2}, {webmachine_mochiweb,loop,1}]}}

4

3 に答える 3

4

to_json/2 関数を定義する必要があります。

例えば:

to_json(RD, Result) ->
    {mochijson:encode(Result), RD, Result}.
于 2011-12-07T00:10:54.827 に答える
0

残念ながら、Ilyaの回答にコメントするという評判はありません。

TLDRto_json定義したモジュールの名前のプレフィックス

長い答え:

別のモジュールでto_jsonを定義しています

呼び出しを見るとcontent_types_accepted/2、どのモジュールがto_json存在するかを指定していないため、undefエラーが発生します。Erlang関数呼び出しは常にMFA->module:function(arguments)であり、関数が同じモジュール内にある場合にのみモジュールを省略できます。

Erlangパッケージのドキュメントも参照してください

于 2012-01-07T11:14:25.813 に答える
0

このエラーを理解する鍵は、次の部分です。

{error, {error,undef, [{customer_update,to_json, ...

エラーを報告しundefます。この種のエラーについては、次の場所で説明されています。

http://www.erlang.org/doc/reference_manual/errors.html#id81244

undefこれは、未定義の関数があることを意味します。customer_update:to_json(..)エラーは、存在しなかった呼び出しによるものです。それがあなたがここで抱えている問題です。

于 2012-01-07T12:35:43.847 に答える