You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by wi...@apache.org on 2017/09/12 12:53:08 UTC

[couchdb] 03/03: Log unhandled mango errors

This is an automated email from the ASF dual-hosted git repository.

willholley pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit cf00dc26447ed44d3a8be0d77e4923367b02bb6b
Author: Will Holley <wi...@gmail.com>
AuthorDate: Mon Sep 11 18:12:16 2017 +0100

    Log unhandled mango errors
---
 src/mango/src/mango_httpd.erl | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/mango/src/mango_httpd.erl b/src/mango/src/mango_httpd.erl
index 33e0c1c..d3ebf48 100644
--- a/src/mango/src/mango_httpd.erl
+++ b/src/mango/src/mango_httpd.erl
@@ -38,13 +38,13 @@ handle_req(#httpd{} = Req, Db0) ->
         handle_req_int(Req, Db)
     catch
         throw:{mango_error, Module, Reason} ->
-            %Stack = erlang:get_stacktrace(),
-            {Code, ErrorStr, ReasonStr} = mango_error:info(Module, Reason),
-            Resp = {[
-                {<<"error">>, ErrorStr},
-                {<<"reason">>, ReasonStr}
-            ]},
-            chttpd:send_json(Req, Code, Resp)
+            case mango_error:info(Module, Reason) of
+            {500, ErrorStr, ReasonStr} ->
+                Stack = erlang:get_stacktrace(),
+                chttpd:send_error(Req, 500, [], ErrorStr, ReasonStr, Stack);
+            {Code, ErrorStr, ReasonStr} ->
+                chttpd:send_error(Req, Code, ErrorStr, ReasonStr)
+            end
     end.
 
 

-- 
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.