Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Khramtsov <ekhramtsov@process-one.net>2019-06-26 00:05:41 +0300
committerEvgeny Khramtsov <ekhramtsov@process-one.net>2019-06-26 00:05:41 +0300
commitb479fe5315164e2091afc2fc379446c5c476bcb0 (patch)
tree9dd9646bd95ca5414e269813aeec00ac3dcdb0f0 /src/mod_http_api.erl
parent6697a3e3f104a552af0b7023aa3a07be1ded79c0 (diff)
Use correct stacktrace in logging macros
By calling erlang:get_stacktrace() inside a lager function we obtain actually a stacktrace of the lager function, not the one we got during exception. This is not a problem for newest Erlang versions though.
Diffstat (limited to 'src/mod_http_api.erl')
-rw-r--r--src/mod_http_api.erl9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/mod_http_api.erl b/src/mod_http_api.erl
index 4dd48158a..fbbdb648d 100644
--- a/src/mod_http_api.erl
+++ b/src/mod_http_api.erl
@@ -192,7 +192,8 @@ process([Call], #request{method = 'POST', data = Data, ip = IPPort} = Req) ->
?DEBUG("Bad Request: ~p", [_Err]),
badrequest_response(<<"Invalid JSON input">>);
?EX_RULE(_Class, _Error, Stack) ->
- ?DEBUG("Bad Request: ~p ~p", [_Error, ?EX_STACK(Stack)]),
+ StackTrace = ?EX_STACK(Stack),
+ ?DEBUG("Bad Request: ~p ~p", [_Error, StackTrace]),
badrequest_response()
end;
process([Call], #request{method = 'GET', q = Data, ip = {IP, _}} = Req) ->
@@ -209,7 +210,8 @@ process([Call], #request{method = 'GET', q = Data, ip = {IP, _}} = Req) ->
throw:{error, unknown_command} ->
json_format({404, 44, <<"Command not found.">>});
?EX_RULE(_, _Error, Stack) ->
- ?DEBUG("Bad Request: ~p ~p", [_Error, ?EX_STACK(Stack)]),
+ StackTrace = ?EX_STACK(Stack),
+ ?DEBUG("Bad Request: ~p ~p", [_Error, StackTrace]),
badrequest_response()
end;
process([_Call], #request{method = 'OPTIONS', data = <<>>}) ->
@@ -296,10 +298,11 @@ handle(Call, Auth, Args, Version) when is_atom(Call), is_list(Args) ->
throw:Msg when is_list(Msg); is_binary(Msg) ->
{400, iolist_to_binary(Msg)};
?EX_RULE(Class, Error, Stack) ->
+ StackTrace = ?EX_STACK(Stack),
?ERROR_MSG("REST API Error: "
"~s(~p) -> ~p:~p ~p",
[Call, hide_sensitive_args(Args),
- Class, Error, ?EX_STACK(Stack)]),
+ Class, Error, StackTrace]),
{500, <<"internal_error">>}
end.