Skip to content

Commit

Permalink
added global exception handler with stack trace
Browse files Browse the repository at this point in the history
  • Loading branch information
hakasapl committed Jul 23, 2024
1 parent 8502458 commit d2d146b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [0.4.4] - UNRELEASED

- Fixed non ASCII characters in loose file extension causing crashes
- Added global exception handler w/ stack trace

## [0.4.3] - 2024-07-22

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ endfunction()
find_package(spdlog REQUIRED CONFIG)
find_package(bsa REQUIRED CONFIG)
find_package(CLI11 REQUIRED CONFIG)
find_package(Boost REQUIRED COMPONENTS filesystem)
find_package(Boost REQUIRED COMPONENTS filesystem stacktrace_windbg)
find_package(directxtk REQUIRED)
find_package(directxtex REQUIRED CONFIG)
find_package(miniz REQUIRED CONFIG)
Expand Down
7 changes: 3 additions & 4 deletions src/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <spdlog/sinks/basic_file_sink.h>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <boost/stacktrace.hpp>

#include "BethesdaGame/BethesdaGame.hpp"
#include "ParallaxGen/ParallaxGen.hpp"
Expand Down Expand Up @@ -271,16 +272,14 @@ void mainRunner(int argc, char** argv)
if (!no_cleanup) {
pg.deleteMeshes();
}

// Close Console
exitWithUserInput(0);
}

int main(int argc, char** argv) {
try {
mainRunner(argc, argv);
exitWithUserInput(0);
} catch (const exception& ex) {
spdlog::critical("An unhandled exception occured, provide this message in your bug report: {}", ex.what());
spdlog::critical("An unhandled exception occurred (Please provide this entire message in your bug report).\n\nException type: {}\nMessage: {}\nStack Trace: \n{}", typeid(ex).name(), ex.what(), boost::stacktrace::to_string(boost::stacktrace::stacktrace()));
exitWithUserInput(1);
}
}
3 changes: 2 additions & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"features": [
"wchar"
]
}
},
"boost-stacktrace"
]
}

0 comments on commit d2d146b

Please sign in to comment.