Skip to content

fogesque/errors

Repository files navigation

errors

C++ errors logo

C++ Standard MIT License Linux Build

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.

Features

  • 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

Dependencies

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.

Building the Project

  1. Clone the repository and initialize vcpkg dependencies:

    git clone https://github.com/fogesque/errors.git
    cd errors
    vcpkg install
  2. Configure the project with CMake

    cmake -S . -B build
  3. Build examples and tests:

    cmake --build build

Running Examples

After building, run the examples binary:

./build/bin/examples/cpp_errors_examples

Running Tests

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.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

C++ errors package for transparent errors handling copied from Go concepts

Resources

License

Stars

Watchers

Forks

Packages

No packages published