Commits

Anonymous committed 1406075

500 on exception in handle_req

  • Participants
  • Parent commits 2ae9df3

Comments (0)

Files changed (2)

File deps/webmachine/src/webmachine_decision_core.erl

 	    Reason = {none, none, []},
 	    {ErrorHTML,ReqState} = ErrorHandler:render_error(
                           Code, {webmachine_request,get(reqstate)}, Reason),
-            put(reqstate, ReqState),
+            put(reqstate, ReqState), 
             wrcall({set_resp_body, ErrorHTML});
         304 ->
             wrcall({remove_resp_header, "Content-Type"}),

File deps/webmachine/src/webmachine_mochiweb.erl

                                               PathTokens,AppRoot,StringPath),
             XReq1 = {webmachine_request,RS1},
             {ok,RS2} = XReq1:set_metadata('resource_module', Mod),
-            webmachine_decision_core:handle_request(Resource, RS2)
+            try 
+                webmachine_decision_core:handle_request(Resource, RS2)
+            catch
+                error:_ -> 
+                    FailReq = {webmachine_request,RS2},
+                    {ok,RS3} = FailReq:send_response(500),
+                    PostFailReq = {webmachine_request,RS3},
+                    {LogData,_RS4} = PostFailReq:log_data(),
+                    case application:get_env(webmachine,
+                                             webmachine_logger_module) of
+                        {ok, LogModule} ->
+                            spawn(LogModule, log_access, [LogData]);
+                        _ -> nop
+                    end
+            end
     end.
 
 get_option(Option, Options) ->