diff options
| author | Dan Engelbrecht <[email protected]> | 2024-04-04 14:32:40 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-04-04 14:32:40 +0200 |
| commit | 12b7bf1c16f671c83840961c37a339141a7ffbb3 (patch) | |
| tree | 3c503e6e1cd4d53b87c1baebcf9286ca8b72db06 /src/zenserver/main.cpp | |
| parent | hardening parsepackagemessage (#38) (diff) | |
| download | zen-12b7bf1c16f671c83840961c37a339141a7ffbb3.tar.xz zen-12b7bf1c16f671c83840961c37a339141a7ffbb3.zip | |
improved assert (#37)
- Improvement: Add file and line to ASSERT exceptions
- Improvement: Catch call stack when throwing assert exceptions and log/output call stack at important places to provide more context to caller
Diffstat (limited to 'src/zenserver/main.cpp')
| -rw-r--r-- | src/zenserver/main.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/zenserver/main.cpp b/src/zenserver/main.cpp index 7a6d2dd22..6b31dc82e 100644 --- a/src/zenserver/main.cpp +++ b/src/zenserver/main.cpp @@ -247,7 +247,12 @@ ZenEntryPoint::Run() Server.Run(); } - catch (std::exception& e) + catch (const AssertException& AssertEx) + { + ZEN_CRITICAL("Caught assert exception in main for process {}: {}", zen::GetCurrentProcessId(), AssertEx.FullDescription()); + RequestApplicationExit(1); + } + catch (const std::exception& e) { ZEN_CRITICAL("Caught exception in main for process {}: {}", zen::GetCurrentProcessId(), e.what()); RequestApplicationExit(1); @@ -407,7 +412,12 @@ main(int argc, char* argv[]) return App.Run(); #endif } - catch (std::exception& Ex) + catch (const AssertException& AssertEx) + { + fprintf(stderr, "ERROR: Caught assert exception in main: '%s'", AssertEx.FullDescription().c_str()); + return 1; + } + catch (const std::exception& Ex) { fprintf(stderr, "ERROR: Caught exception in main: '%s'", Ex.what()); |