https://github.com/voldien/exceptcxx
Universal C++ Exception Library with StackTrace Builtin and Unicode Text Support
https://github.com/voldien/exceptcxx
cross-platform cxx11 exception exception-messages stacktrace
Last synced: 6 months ago
JSON representation
Universal C++ Exception Library with StackTrace Builtin and Unicode Text Support
- Host: GitHub
- URL: https://github.com/voldien/exceptcxx
- Owner: voldien
- License: mit
- Created: 2021-09-14T07:58:50.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-11-17T12:29:03.000Z (11 months ago)
- Last Synced: 2025-03-25T20:21:23.417Z (7 months ago)
- Topics: cross-platform, cxx11, exception, exception-messages, stacktrace
- Language: C++
- Homepage:
- Size: 102 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ExecptCXX
[](https://github.com/voldien/exceptcxx/actions/workflows/ci.yml)
[](https://opensource.org/licenses/MIT)
[](https://github.com/voldien/exceptcxx/releases)A simple library for adding universal exceptions more additional meta than the common _std::exception_ while preserving the original code when integrating.
## Features
* StackTrace - Support to get the stack tree of when it was invoked.
* Unicode - Allow support for both ASCII, Unicode 8, and unicode 16.
* Backward compadible with standard exception.## Motivation
Attempt to create a dedicated Exception library with useful debug info and stack trace info while maintaining the standard c++ exception. Allowing to reuse the code in multiple projects with a good level of information when the exception is thrown.
## Installation
The library can be built simply by the following commands.
```bash
mkdir build
cd build
cmake ..
make
```A note, this exception library is using external submodule git. Use the following command to download all the dependent git repositories.
```bash
git submodule update --init --recursive
```## Integration with CMake
The idea is to be able to integrate this library with another project easily. With CMake, it basically requires 2 lines. One for adding the project and the second for adding it as a dependent linked library target.
```cmake
ADD_SUBDIRECTORY(exceptCXX EXCLUDE_FROM_ALL)
``````cmake
TARGET_LINK_LIBRARIES(myTarget PUBLIC cxxexcept)
```## Dependencies
The dependices currently is related to backward-cpp
```bash
apt install binutils-dev
```## Examples
The following is a simple example for throwing an exception, followed by printing a formated
error message to stdout.```cpp
try {
throw cxxexcept::DivideByZeroException();
} catch (const std::exception &ex) {
cxxexcept::printStackMessage(ex);
}```
Another example, using a more common exception type, runtime exception.
```cpp
try {
throw cxxexcept::RuntimeException();
} catch (const std::exception &ex) {
cxxexcept::printStackMessage(ex);
}```
Getting a comprehensive string of both the stack as well the cause of exception can be extracted with the following method.
```cpp
std::cerr << cxxexcept::getStackMessage(ex);
```## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details