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
This commit is contained in:
eldritch horrors 2024-03-21 23:06:00 +01:00
parent c777dcd1ae
commit dd06f9b792

View file

@ -19,5 +19,5 @@ public:
Finally(Finally &&other) : fun(std::move(other.fun)) { Finally(Finally &&other) : fun(std::move(other.fun)) {
other.movedFrom = true; other.movedFrom = true;
} }
~Finally() { if (!movedFrom) fun(); } ~Finally() noexcept(false) { if (!movedFrom) fun(); }
}; };