A modern C++ error handling package inspired by Go's error concept. This library provides transparent, composable, and type-safe error management for C++ projects, making error handling more robust and expressive.
- Simple error creation and propagation
- Error wrapping with context
- Joining multiple errors
- Type-safe error matching and extraction
- API closely modeled after Go's standard
errors
package
Note: Since package was built and tested on Ubuntu, there will be instructions how to setup environment on this operating system.
To use this package in your projects, you will need:
- C++ compiler with support at least C++17 standard
To build examples and tests in this repo, you will need:
- GCC 14 / G++ 14 (with C++23 support)
sudo apt install gcc-14 g++-14
Use update-alternatives
to switch between compiler versions.
- CMake (>=3.15)
sudo apt install cmake
- Ninja (can be switched to other build tool)
sudo apt install ninja-build
- vcpkg (for dependency management)
See vcpkg Quick Start for setting up vcpkg.
-
Clone the repository and initialize vcpkg dependencies:
git clone https://github.com/fogesque/errors.git cd errors vcpkg install
-
Configure the project with CMake
cmake -S . -B build
-
Build examples and tests:
cmake --build build
After building, run the examples binary:
./build/bin/examples/cpp_errors_examples
After building, run the test binary:
./build/bin/tests/cpp_errors_tests
All tests are written using GoogleTest and will verify the correctness of the error handling API.
This project is licensed under the MIT License. See the LICENSE file for details.