Also log the error.
This commit is contained in:
parent
dcbc5957df
commit
d89fc6926a
|
|
@ -99,12 +99,12 @@ reply(Facts, ReqData, Context) ->
|
|||
try
|
||||
{mochijson2:encode(Facts), ReqData1, Context}
|
||||
catch
|
||||
exit:{json_encode, Error} ->
|
||||
halt_response(
|
||||
500,
|
||||
iolist_to_binary(io_lib:format("JSON encode error: ~p", [Error])),
|
||||
iolist_to_binary(io_lib:format("While encoding:~n~p", [Facts])),
|
||||
ReqData1, Context)
|
||||
exit:{json_encode, E} ->
|
||||
Error = iolist_to_binary(
|
||||
io_lib:format("JSON encode error: ~p", [E])),
|
||||
Reason = iolist_to_binary(
|
||||
io_lib:format("While encoding:~n~p", [Facts])),
|
||||
internal_server_error(Error, Reason, ReqData1, Context)
|
||||
end.
|
||||
|
||||
reply_list(Facts, ReqData, Context) ->
|
||||
|
|
@ -163,6 +163,10 @@ not_authorised(Reason, ReqData, Context) ->
|
|||
not_found(Reason, ReqData, Context) ->
|
||||
halt_response(404, not_found, Reason, ReqData, Context).
|
||||
|
||||
internal_server_error(Error, Reason, ReqData, Context) ->
|
||||
rabbit_log:error("~s~n~s~n", [Error, Reason]),
|
||||
halt_response(500, Error, Reason, ReqData, Context).
|
||||
|
||||
halt_response(Code, Type, Reason, ReqData, Context) ->
|
||||
Json = {struct, [{error, Type},
|
||||
{reason, rabbit_mgmt_format:tuple(Reason)}]},
|
||||
|
|
|
|||
Loading…
Reference in New Issue