diff options
author | Paul Joseph Davis <davisp@apache.org> | 2011-11-21 18:16:12 -0600 |
---|---|---|
committer | Paul Joseph Davis <davisp@apache.org> | 2011-11-21 18:16:12 -0600 |
commit | 9292f8dd115a9eb15cfc750b08fb3f1df128a76e (patch) | |
tree | 2bfd6b60a02c04e71c5d0d97620773473003ebbf | |
parent | 1c669e41c6bf0a8bb9db45cf4cb156bdc58aff50 (diff) | |
download | couchdb-9292f8dd115a9eb15cfc750b08fb3f1df128a76e.tar.gz |
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.
-rw-r--r-- | src/couchdb/couch_httpd.erl | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl index 5b5a8b615..d668f98c2 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), |