All Projects → GPMueller → mwe-cpp-exception

GPMueller / mwe-cpp-exception

Licence: MIT license
Minimum working example of proper C++11 exception handling

Programming Languages

C++
36643 projects - #6 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to mwe-cpp-exception

ExceptionCatcher
Catch Objective-C exceptions in Swift
Stars: ✭ 97 (+385%)
Mutual labels:  exceptions, exception-handler
DuckOS
Such OS; Very Duck!
Stars: ✭ 16 (-20%)
Mutual labels:  exceptions, exception-handling
Traceback with variables
Adds variables to python traceback. Simple, lightweight, controllable. Debug reasons of exceptions by logging or pretty printing colorful variable contexts for each frame in a stacktrace, showing every value. Dump locals environments after errors to console, files, and loggers. Works in Jupyter and IPython. Install with pip or conda.
Stars: ✭ 509 (+2445%)
Mutual labels:  exceptions, exception-handling
Bugsnag React Native
Error monitoring and reporting tool for native exceptions and JS errors in React Native apps
Stars: ✭ 374 (+1770%)
Mutual labels:  exceptions, exception-handling
stack-trace-art
Turning programming exceptions into art
Stars: ✭ 39 (+95%)
Mutual labels:  exceptions, exception-handling
Bugsnag Php
Bugsnag error monitoring and crash reporting tool for PHP apps
Stars: ✭ 475 (+2275%)
Mutual labels:  exceptions, exception-handling
Sosl
StackOverflow Search Library
Stars: ✭ 10 (-50%)
Mutual labels:  exceptions, exception-handling
Bugsnag Js
Javascript error handling tool for Bugsnag. Monitor and report JavaScript bugs & errors.
Stars: ✭ 625 (+3025%)
Mutual labels:  exceptions, exception-handling
Object Oriented Programming Using Python
Python is a multi-paradigm programming language. Meaning, it supports different programming approach. One of the popular approach to solve a programming problem is by creating objects. This is known as Object-Oriented Programming (OOP).
Stars: ✭ 183 (+815%)
Mutual labels:  exceptions, exception-handling
Coderr.server
Replace logfiles with Coderr to correct bugs faster and more efficiently.
Stars: ✭ 92 (+360%)
Mutual labels:  exceptions, exception-handling
05 Python Files
Python too supports file handling and allows users to handle files i.e., to read and write files, along with many other file handling options, to operate on files. The concept of file handling has stretched over various other languages, but the implementation is either complicated or lengthy, but like other concepts of Python, this concept here …
Stars: ✭ 163 (+715%)
Mutual labels:  exceptions, exception-handling
bugsnag-java
Bugsnag error reporting for Java.
Stars: ✭ 51 (+155%)
Mutual labels:  exceptions, exception-handling
crash
Proper error handling, exceptions and try/catch for ZSH
Stars: ✭ 51 (+155%)
Mutual labels:  exceptions, exception-handler
raise if
one liner `raise Exception if condition` for Python
Stars: ✭ 15 (-25%)
Mutual labels:  exceptions, exception-handler
Larabug
Laravel error reporting tool
Stars: ✭ 84 (+320%)
Mutual labels:  exceptions, exception-handling
Exceptions4c
🐑 An exception handling framework for C
Stars: ✭ 189 (+845%)
Mutual labels:  exceptions, exception-handling
Coderr.Client
Core client library for Coderr
Stars: ✭ 23 (+15%)
Mutual labels:  exceptions, exception-handling
FPChecker
A dynamic analysis tool to detect floating-point errors in HPC applications.
Stars: ✭ 26 (+30%)
Mutual labels:  exceptions
ErrorControlSystem
ErrorControlSystem is a .NET library created to automate handling .NET Windows-Base application exceptions and raise that to a sql server. This exception handler have some features as screen capturing, fetch server date time in exception occurrence time and etc.
Stars: ✭ 30 (+50%)
Mutual labels:  exception-handler
loggit
Modern Logging for the R Ecosystem
Stars: ✭ 34 (+70%)
Mutual labels:  exception-handler

Proper, portable exception handling with backtracing in C++11

Build Status

See GPMueller/trace for a proper exception backtracing library.

This MWE shows how std::nested_exception and std::throw_with_nested can be applied in order to not lose information while propagating an original std::exception upwards through a chain of function calls and create a backtrace without any overhead (compare e.g. logging of debug messages). This avoids much of the need for any debugging and provides a way of ensuring that a library does not crash ungracefully. Output should look something like this:

Library API: Exception caught in function 'api_function'
Backtrace:
~/Git/mwe-cpp-exception/src/detail/Library.cpp:17 : library_function failed
~/Git/mwe-cpp-exception/src/detail/Library.cpp:13 : could not open file "nonexistent.txt"

The example may seem a bit overkill, displaying a library with an API layer, but it shows a thorough way of dealing cleanly with exceptions. main calls an API function, which in turn calls a library function which deliberately throws. The API function catches the exception and calls a handler function.

Inspiration for this MWE was taken from https://stackoverflow.com/a/37227893/4069571 and https://stackoverflow.com/a/348862/4069571

Build

CMake is used to configure the build. To build the executable:

mkdir -p build
cd build
cmake ..
cmake --build .

TODO

  • Extend this MWE with example exceptions which do not require the code to terminate.
  • Create unit tests with catch, using e.g. REQUIRE_THROWS
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].