diff --git a/src/commands.cc b/src/commands.cc index 6907344b..089db654 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -1563,7 +1563,14 @@ void context_wrap(const ParametersParser& parser, Context& context, Func func) auto& register_manager = RegisterManager::instance(); auto make_register_restorer = [&](char c) { return on_scope_end([&, c, save=register_manager[c].get(context) | gather>()] { - RegisterManager::instance()[c].set(context, save); + try + { + RegisterManager::instance()[c].set(context, save); + } + catch (runtime_error& err) + { + write_to_debug_buffer(format("failed to restore register '{}': {}", c, err.what())); + } }); }; Vector saved_registers; diff --git a/src/utils.hh b/src/utils.hh index 23afdeb1..f21be9c1 100644 --- a/src/utils.hh +++ b/src/utils.hh @@ -73,7 +73,7 @@ public: { other.m_valid = false; } [[gnu::always_inline]] - ~OnScopeEnd() { if (m_valid) m_func(); } + ~OnScopeEnd() noexcept(noexcept(std::declval()())) { if (m_valid) m_func(); } private: bool m_valid;