mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Improve the error message for HTTP handlers
Making it look more like the websocket handler error messages.
This commit is contained in:
parent
0e84e7f920
commit
eff9477201
1 changed files with 8 additions and 4 deletions
|
@ -212,8 +212,10 @@ handler_init(Req, State=#state{listener=ListenerPid,
|
||||||
catch Class:Reason ->
|
catch Class:Reason ->
|
||||||
error_terminate(500, State),
|
error_terminate(500, State),
|
||||||
error_logger:error_msg(
|
error_logger:error_msg(
|
||||||
"** Handler ~p terminating in init/3 for the reason ~p:~p~n"
|
"** Handler ~p terminating in init/3~n"
|
||||||
"** Options were ~p~n** Request was ~p~n** Stacktrace: ~p~n~n",
|
" for the reason ~p:~p~n"
|
||||||
|
"** Options were ~p~n"
|
||||||
|
"** Request was ~p~n** Stacktrace: ~p~n~n",
|
||||||
[Handler, Class, Reason, Opts, Req, erlang:get_stacktrace()])
|
[Handler, Class, Reason, Opts, Req, erlang:get_stacktrace()])
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -224,7 +226,8 @@ handler_loop(HandlerState, Req, State=#state{handler={Handler, Opts}}) ->
|
||||||
next_request(HandlerState2, Req2, State)
|
next_request(HandlerState2, Req2, State)
|
||||||
catch Class:Reason ->
|
catch Class:Reason ->
|
||||||
error_logger:error_msg(
|
error_logger:error_msg(
|
||||||
"** Handler ~p terminating in handle/2 for the reason ~p:~p~n"
|
"** Handler ~p terminating in handle/2~n"
|
||||||
|
" for the reason ~p:~p~n"
|
||||||
"** Options were ~p~n** Handler state was ~p~n"
|
"** Options were ~p~n** Handler state was ~p~n"
|
||||||
"** Request was ~p~n** Stacktrace: ~p~n~n",
|
"** Request was ~p~n** Stacktrace: ~p~n~n",
|
||||||
[Handler, Class, Reason, Opts,
|
[Handler, Class, Reason, Opts,
|
||||||
|
@ -239,7 +242,8 @@ handler_terminate(HandlerState, Req, #state{handler={Handler, Opts}}) ->
|
||||||
Handler:terminate(Req#http_req{resp_state=locked}, HandlerState)
|
Handler:terminate(Req#http_req{resp_state=locked}, HandlerState)
|
||||||
catch Class:Reason ->
|
catch Class:Reason ->
|
||||||
error_logger:error_msg(
|
error_logger:error_msg(
|
||||||
"** Handler ~p terminating in terminate/2 for the reason ~p:~p~n"
|
"** Handler ~p terminating in terminate/2~n"
|
||||||
|
" for the reason ~p:~p~n"
|
||||||
"** Options were ~p~n** Handler state was ~p~n"
|
"** Options were ~p~n** Handler state was ~p~n"
|
||||||
"** Request was ~p~n** Stacktrace: ~p~n~n",
|
"** Request was ~p~n** Stacktrace: ~p~n~n",
|
||||||
[Handler, Class, Reason, Opts,
|
[Handler, Class, Reason, Opts,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue