#include#include int main() { auto err = cppes::errc::invalid_argument; std::cout << "Error code: " << static_cast (err) << ", Message: " << err.message() << std::endl; return 0; }
#includeIn this example, we include the `exception.hpp` header from the `error_success` library. We define a function `foo` that throws an exception with the `invalid_argument` error code if the input `x` is negative. In `main()`, we call `foo(-1)` inside a try-catch block and catch the exception, printing its error message. Package/Library: error_success.#include void foo(int x) { if (x < 0) throw cppes::exception(cppes::errc::invalid_argument); } int main() { try { foo(-1); } catch (cppes::exception& e) { std::cout << "Error: " << e.code().message() << std::endl; } return 0; }