aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2018-08-13 17:23:48 +0200
committerLoïc Hoguin <[email protected]>2018-08-13 17:23:48 +0200
commit0a5fadc60bc586946ebd3b17839bcaf13b76f6d0 (patch)
tree4e8122d59c486273d894296c0aba502f155e3687 /src
parent06a3a93de0bb6bdd0759f658b7826f38a50bb8a6 (diff)
downloadcowboy-0a5fadc60bc586946ebd3b17839bcaf13b76f6d0.tar.gz
cowboy-0a5fadc60bc586946ebd3b17839bcaf13b76f6d0.tar.bz2
cowboy-0a5fadc60bc586946ebd3b17839bcaf13b76f6d0.zip
Improve errors for when the ProvideCallback is missing
Diffstat (limited to 'src')
-rw-r--r--src/cowboy_rest.erl7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/cowboy_rest.erl b/src/cowboy_rest.erl
index c73ee53..2780a90 100644
--- a/src/cowboy_rest.erl
+++ b/src/cowboy_rest.erl
@@ -1069,7 +1069,7 @@ set_resp_body_expires(Req, State) ->
%% Set the response headers and call the callback found using
%% content_types_provided/2 to obtain the request body and add
%% it to the response.
-set_resp_body(Req, State=#state{content_type_a={_, Callback}}) ->
+set_resp_body(Req, State=#state{handler=Handler, content_type_a={_, Callback}}) ->
try case call(Req, State, Callback) of
{stop, Req2, HandlerState2} ->
terminate(Req2, State#state{handler_state=HandlerState2});
@@ -1079,8 +1079,9 @@ set_resp_body(Req, State=#state{content_type_a={_, Callback}}) ->
State2 = State#state{handler_state=HandlerState2},
Req3 = cowboy_req:set_resp_body(Body, Req2),
multiple_choices(Req3, State2)
- end catch Class:Reason = {case_clause, no_call} ->
- error_terminate(Req, State, Class, Reason)
+ end catch Class:{case_clause, no_call} ->
+ error_terminate(Req, State, Class, {error, {missing_callback, {Handler, Callback, 2}},
+ 'A callback specified in content_types_provided/2 is not exported.'})
end.
multiple_choices(Req, State) ->