Shows how to use xtd::exception exception.
#include <xtd/xtd>
namespace user_defined_exception {
class employee_list_not_found_exception : public exception {
public:
employee_list_not_found_exception(const diagnostics::stack_frame& frame = diagnostics::stack_frame::current()) : exception {"The employee list does not exist."_t, frame} {
}
employee_list_not_found_exception(const string& message, const diagnostics::stack_frame& frame = diagnostics::stack_frame::current()) : exception {message, frame} {
}
template<typename exception_t>
employee_list_not_found_exception(const string& message, const exception_t& inner, const diagnostics::stack_frame& frame = diagnostics::stack_frame::current()) : exception {message, inner, frame} {
}
};
}
auto main() -> int {
try {
throw user_defined_exception::employee_list_not_found_exception {};
} catch(const exception& e) {
console::write_line(
"type = {}",
e.get_type());
console::write_line(
"help_link = {}",
e.help_link());
console::write_line(
"h_result = 0x{0:X8} ({0})",
static_cast<uint32>(
e.h_result()));
console::write_line(
"inner_exception = {}",
e.inner_exception());
console::write_line(
"message = {}",
e.message());
console::write_line(
"source = {}",
e.source());
console::write_line(
"stack_trace = {}",
e.stack_trace());
}
}
std::uint32_t uint32
Represents a 32-bit unsigned integer.
Definition uint32.hpp:23
@ e
The E key.
Definition console_key.hpp:96