/* SPDX-License-Identifier: MIT Copyright © 2023-2025 Amebis */ #pragma once #include "compat.hpp" #include namespace stdex { /// /// User cancelled exception /// class user_cancelled : public std::runtime_error { public: /// /// Constructs an exception /// /// \param[in] msg Error message /// user_cancelled(_In_opt_z_ const char* msg = "operation cancelled") : runtime_error(msg) {} }; /// /// Concatenates error messages when exception is nested. /// /// \param ex Exception /// /// \returns Concatenated exception messages with ": " delimiter. /// inline std::string exception_msg(const std::exception& ex) { try { std::rethrow_if_nested(ex); } catch (const std::exception& nested_ex) { return std::string(ex.what()) + ": " + exception_msg(nested_ex); } catch (...) {} return ex.what(); } }