Anonymous avatar Anonymous committed c25ec2d

trim the reqdata/reqstate loop in tracebacks

Comments (0)

Files changed (3)

src/webmachine_error_handler.erl

 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) ->

src/webmachine_request.erl

 
 % actual interface for resource functions
 -export([
+         trim_state/0,
          get_reqdata/0,
          set_reqdata/1,
 	 socket/0,
 -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 ->

src/webmachine_resource.erl

             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;
     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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.