diff options
author | Will Holley <willholley@gmail.com> | 2017-09-11 18:12:16 +0100 |
---|---|---|
committer | Will Holley <willholley@gmail.com> | 2017-09-12 13:53:02 +0100 |
commit | cf00dc26447ed44d3a8be0d77e4923367b02bb6b (patch) | |
tree | 5e622264522d6bf2e3c7343dd81ec0db48243a99 | |
parent | 302126b75b124f4f00a8c9629b086c8b92d42784 (diff) | |
download | couchdb-cf00dc26447ed44d3a8be0d77e4923367b02bb6b.tar.gz |
Log unhandled mango errors
-rw-r--r-- | src/mango/src/mango_httpd.erl | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/mango/src/mango_httpd.erl b/src/mango/src/mango_httpd.erl index 33e0c1c41..d3ebf48c9 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. |