From dd06f9b792638b9c48265b223d095859990d3b26 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Thu, 21 Mar 2024 23:06:00 +0100 Subject: [PATCH] libutil: make ~Finally noexcept(false) this is supposed to act like a finally block does in other languages. a finally block should be able to throw exceptions of its own rather than just crashing the entire program when it throws it own exceptions. even in the rare case of a finally throwing an unexpected exception it might be better to report the exception from Finally instead of the original, at least that can keep our program running instead of letting it crash. Change-Id: Id42011e46b1df369152b4564938c0e93fa1acf32 --- src/libutil/finally.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libutil/finally.hh b/src/libutil/finally.hh index 49263ee6d..f2293e5d4 100644 --- a/src/libutil/finally.hh +++ b/src/libutil/finally.hh @@ -19,5 +19,5 @@ public: Finally(Finally &&other) : fun(std::move(other.fun)) { other.movedFrom = true; } - ~Finally() { if (!movedFrom) fun(); } + ~Finally() noexcept(false) { if (!movedFrom) fun(); } };