Permalink
Browse files

trim the reqdata/reqstate loop in tracebacks

  • Loading branch information...
justin@basho.com
justin@basho.com committed Dec 11, 2009
1 parent 6be5b74 commit 41ba5121ebf001ecc4f0d567e5201780d4737f2d
Showing with 13 additions and 2 deletions.
  1. +1 −1 src/webmachine_error_handler.erl
  2. +5 −0 src/webmachine_request.erl
  3. +7 −1 src/webmachine_resource.erl
@@ -28,7 +28,7 @@
render_error(Code, Req, Reason) ->
case Req:has_response_body() of
{true,_} -> Req:response_body();
- {false,_} -> render_error_body(Code, Req, Reason)
+ {false,_} -> render_error_body(Code, Req:trim_state(), Reason)
end.
render_error_body(404, Req, _Reason) ->
@@ -26,6 +26,7 @@
% actual interface for resource functions
-export([
+ trim_state/0,
get_reqdata/0,
set_reqdata/1,
socket/0,
@@ -82,6 +83,10 @@
-define(QUIP, "that tip is the fix").
-define(IDLE_TIMEOUT, infinity).
+trim_state() ->
+ TrimData = (ReqState#reqstate.reqdata)#wm_reqdata{wm_state='WMSTATE'},
+ webmachine_request:new(ReqState#reqstate{reqdata=TrimData}).
+
get_peer() ->
case ReqState#reqstate.peer of
undefined ->
@@ -149,6 +149,12 @@ handle_wm_call(Fun, ReqData) ->
end
end.
+trim_trace([{M,F,[RD = #wm_reqdata{},S]}|STRest]) ->
+ TrimState = (RD#wm_reqdata.wm_state)#reqstate{reqdata='REQDATA'},
+ TrimRD = RD#wm_reqdata{wm_state=TrimState},
+ [{M,F,[TrimRD,S]}|STRest];
+trim_trace(X) -> X.
+
resource_call(F, ReqData) ->
case R_Trace of
false -> nop;
@@ -157,7 +163,7 @@ resource_call(F, ReqData) ->
Result = try
apply(R_Mod, F, [ReqData, R_ModState])
catch C:R ->
- Reason = {C, R, erlang:get_stacktrace()},
+ Reason = {C, R, trim_trace(erlang:get_stacktrace())},
{{error, Reason}, ReqData, R_ModState}
end,
case R_Trace of

0 comments on commit 41ba512

Please sign in to comment.