summaryrefslogtreecommitdiff
path: root/src/mango
diff options
context:
space:
mode:
authorJan Lehnardt <jan@apache.org>2021-03-13 18:00:12 +0100
committerJan Lehnardt <jan@apache.org>2021-03-17 15:32:49 +0100
commitbfc25ccd34f77191c0d7329a1e57f4ef6c837dff (patch)
treea01456f202b1bdade288b65277e8ec63db7b915b /src/mango
parent10423740c792a9dcc97b488993b70cbf4f44927e (diff)
downloadcouchdb-bfc25ccd34f77191c0d7329a1e57f4ef6c837dff.tar.gz
feat: work around get_stacktrace deprecation/removal
This patch introduces a macro and inserts it everywhere we catch errors and then generatre a stacktrace. So far the only thing that is a little bit ugly is that in two places, I had to add a header include dependency on couch_db.erl where those modules didn’t have any ties to couchdb/* before, alas. I’d be willing to duplicate the macros in those modules, if we don’t want the include dependency.
Diffstat (limited to 'src/mango')
-rw-r--r--src/mango/src/mango_httpd.erl3
-rw-r--r--src/mango/src/mango_util.erl9
2 files changed, 4 insertions, 8 deletions
diff --git a/src/mango/src/mango_httpd.erl b/src/mango/src/mango_httpd.erl
index 379d2e127..624691bb9 100644
--- a/src/mango/src/mango_httpd.erl
+++ b/src/mango/src/mango_httpd.erl
@@ -37,10 +37,9 @@ handle_req(#httpd{} = Req, Db0) ->
Db = set_user_ctx(Req, Db0),
handle_req_int(Req, Db)
catch
- throw:{mango_error, Module, Reason} ->
+ ?STACKTRACE(throw, {mango_error, Module, Reason}, Stack)
case mango_error:info(Module, Reason) of
{500, ErrorStr, ReasonStr} ->
- Stack = erlang:get_stacktrace(),
chttpd:send_error(Req, {ErrorStr, ReasonStr, Stack});
{Code, ErrorStr, ReasonStr} ->
chttpd:send_error(Req, Code, ErrorStr, ReasonStr)
diff --git a/src/mango/src/mango_util.erl b/src/mango/src/mango_util.erl
index 0d31f15f9..8257e841f 100644
--- a/src/mango/src/mango_util.erl
+++ b/src/mango/src/mango_util.erl
@@ -138,16 +138,13 @@ do_defer(Mod, Fun, Args) ->
Resp ->
erlang:exit({mango_defer_ok, Resp})
catch
- throw:Error ->
- Stack = erlang:get_stacktrace(),
+ ?STACKTRACE(throw, Error, Stack)
couch_log:error("Defered error: ~w~n ~p", [{throw, Error}, Stack]),
erlang:exit({mango_defer_throw, Error});
- error:Error ->
- Stack = erlang:get_stacktrace(),
+ ?STACKTRACE(error, Error, Stack)
couch_log:error("Defered error: ~w~n ~p", [{error, Error}, Stack]),
erlang:exit({mango_defer_error, Error});
- exit:Error ->
- Stack = erlang:get_stacktrace(),
+ ?STACKTRACE(exit, Error, Stack)
couch_log:error("Defered error: ~w~n ~p", [{exit, Error}, Stack]),
erlang:exit({mango_defer_exit, Error})
end.