From c83a47eb0f287160b4b5241c0cd2d7b45ef3190d Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 16 Mar 2018 13:13:33 -0700 Subject: [PATCH] ircd::m: Handle and report hookfn exception. --- include/ircd/m/hook.h | 2 ++ ircd/m/m.cc | 24 +++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/ircd/m/hook.h b/include/ircd/m/hook.h index 71abca565..d4094347c 100644 --- a/include/ircd/m/hook.h +++ b/include/ircd/m/hook.h @@ -65,6 +65,8 @@ struct ircd::m::hook::site bool add(hook &); bool del(hook &); + void call(hook &, const event &); + public: void operator()(const event &); diff --git a/ircd/m/m.cc b/ircd/m/m.cc index 63dd36581..e02e954b6 100644 --- a/ircd/m/m.cc +++ b/ircd/m/m.cc @@ -1521,7 +1521,29 @@ ircd::m::hook::site::operator()(const event &event) } for(const auto &hook : matching) - hook->function(event); + call(*hook, event); +} + +void +ircd::m::hook::site::call(hook &hook, + const event &event) +try +{ + hook.function(event); +} +catch(const ctx::interrupted &e) +{ + throw; +} +catch(const std::exception &e) +{ + log::critical + { + "Unhandled hookfn(%p) %s error :%s", + &hook, + string_view{hook.feature}, + e.what() + }; } bool