You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2011/11/22 01:17:05 UTC

git commit: Fix error stack traces

Updated Branches:
  refs/heads/master 1c669e41c -> 9292f8dd1


Fix error stack traces

If you get the stack in an exception handler after calling a function it
gets changed from where the exception was thrown. Fixed simply by
grabbing the stack before making logging calls.


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/9292f8dd
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/9292f8dd
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/9292f8dd

Branch: refs/heads/master
Commit: 9292f8dd115a9eb15cfc750b08fb3f1df128a76e
Parents: 1c669e4
Author: Paul Joseph Davis <da...@apache.org>
Authored: Mon Nov 21 18:16:12 2011 -0600
Committer: Paul Joseph Davis <da...@apache.org>
Committed: Mon Nov 21 18:16:12 2011 -0600

----------------------------------------------------------------------
 src/couchdb/couch_httpd.erl |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/9292f8dd/src/couchdb/couch_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl
index 5b5a8b6..d668f98 100644
--- a/src/couchdb/couch_httpd.erl
+++ b/src/couchdb/couch_httpd.erl
@@ -334,20 +334,24 @@ handle_request_int(MochiReq, DefaultFun,
             ?LOG_ERROR("~s", [ErrorReason]),
             send_error(HttpReq, {bad_otp_release, ErrorReason});
         throw:Error ->
+            Stack = erlang:get_stacktrace(),
             ?LOG_DEBUG("Minor error in HTTP request: ~p",[Error]),
-            ?LOG_DEBUG("Stacktrace: ~p",[erlang:get_stacktrace()]),
+            ?LOG_DEBUG("Stacktrace: ~p",[Stack]),
             send_error(HttpReq, Error);
         error:badarg ->
+            Stack = erlang:get_stacktrace(),
             ?LOG_ERROR("Badarg error in HTTP request",[]),
-            ?LOG_INFO("Stacktrace: ~p",[erlang:get_stacktrace()]),
+            ?LOG_INFO("Stacktrace: ~p",[Stack]),
             send_error(HttpReq, badarg);
         error:function_clause ->
+            Stack = erlang:get_stacktrace(),
             ?LOG_ERROR("function_clause error in HTTP request",[]),
-            ?LOG_INFO("Stacktrace: ~p",[erlang:get_stacktrace()]),
+            ?LOG_INFO("Stacktrace: ~p",[Stack]),
             send_error(HttpReq, function_clause);
         Tag:Error ->
+            Stack = erlang:get_stacktrace(),
             ?LOG_ERROR("Uncaught error in HTTP request: ~p",[{Tag, Error}]),
-            ?LOG_INFO("Stacktrace: ~p",[erlang:get_stacktrace()]),
+            ?LOG_INFO("Stacktrace: ~p",[Stack]),
             send_error(HttpReq, Error)
     end,
     RequestTime = round(timer:now_diff(now(), Begin)/1000),