You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2023/04/04 09:33:47 UTC
[couchdb] 04/05: capture original stack trace
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a commit to branch dreyfus-await-time
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit e8ade9f66ac65ba5ebff5b2ace67ebb5ca328523
Author: Robert Newson <rn...@apache.org>
AuthorDate: Wed Mar 22 13:14:30 2023 +0000
capture original stack trace
---
src/couch_event/src/couch_event_listener_mfa.erl | 27 ++++++++++++++++++------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/src/couch_event/src/couch_event_listener_mfa.erl b/src/couch_event/src/couch_event_listener_mfa.erl
index b4cd9148a..e9b1fa47d 100644
--- a/src/couch_event/src/couch_event_listener_mfa.erl
+++ b/src/couch_event/src/couch_event_listener_mfa.erl
@@ -76,13 +76,26 @@ terminate(_Reason, _MFA) ->
ok.
handle_event(DbName, Event, #st{mod = Mod, func = Func, state = State} = St) ->
- case (catch Mod:Func(DbName, Event, State)) of
- {ok, NewState} ->
- {ok, St#st{state = NewState}};
- stop ->
- {stop, normal, St};
- Else ->
- erlang:error(Else)
+ try
+ case Mod:Func(DbName, Event, State) of
+ {ok, NewState} ->
+ {ok, St#st{state = NewState}};
+ stop ->
+ {stop, normal, St};
+ Else ->
+ couch_log:error("~p: else in handle_event for db ~p, event ~p, else ~p", [?MODULE, DbName, Event, Else]),
+ erlang:error(Else)
+ end
+ catch
+ error:Reason:Stack ->
+ couch_log:error("~p: error in handle_event for db ~p, event ~p, reason ~p, stack ~p", [?MODULE, DbName, Event, Reason, Stack]),
+ erlang:error(Reason);
+ exit:Reason:Stack ->
+ couch_log:error("~p: exit in handle_event for db ~p, event ~p, reason ~p, stack ~p", [?MODULE, DbName, Event, Reason, Stack]),
+ erlang:exit(Reason);
+ throw:Reason:Stack ->
+ couch_log:error("~p: throw in handle_event for db ~p, event ~p, reason ~p, stack ~p", [?MODULE, DbName, Event, Reason, Stack]),
+ erlang:throw(Reason)
end.
handle_cast(shutdown, St) ->