couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject git commit: Fix error stack traces
Date Mon, 19 Mar 2012 12:49:04 GMT
Updated Branches:
  refs/heads/1.2.x 37f5cd1ba -> 84d2d12f0


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/84d2d12f
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/84d2d12f
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/84d2d12f

Branch: refs/heads/1.2.x
Commit: 84d2d12f0cb42a10e1b555ba9ca993fbdff43557
Parents: 37f5cd1
Author: Paul Joseph Davis <davisp@apache.org>
Authored: Mon Nov 21 18:16:12 2011 -0600
Committer: Robert Newson <rnewson@apache.org>
Committed: Mon Mar 19 12:38:29 2012 +0000

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


http://git-wip-us.apache.org/repos/asf/couchdb/blob/84d2d12f/src/couchdb/couch_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl
index 8f33457..7f7eb6c 100644
--- a/src/couchdb/couch_httpd.erl
+++ b/src/couchdb/couch_httpd.erl
@@ -339,20 +339,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),


Mime
View raw message