Add expample of panic handling

This commit is contained in:
Sergey Kuznetsov
2026-04-29 17:42:15 +01:00
parent bc483b2a1d
commit 5be406e2df
2 changed files with 31 additions and 2 deletions

View File

@@ -22,6 +22,17 @@ public:
auto const guard = rs::hello_world::init_logger();
rs::hello_world::log_info("test log message from C++");
BEAST_EXPECT(true);
// Second init should panic; safe_init_logger catches it and throws.
bool caught = false;
try
{
rs::hello_world::safe_init_logger();
}
catch (std::exception const&)
{
caught = true;
}
BEAST_EXPECT(caught);
}
void