Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

Boost Exception

NOTE: When targeting C++11 or newer and Boost 1.75 or newer is available, it is recommended to use Boost LEAF instead of Boost Exception. LEAF serves a similar purpose but it has a more elegant interface, it is more efficient, and works with or without exception handling -- yet understands Boost Exception error information for compatibility with legacy source code. This overview explains the differences between the two APIs (Boost Exception is not deprecated and will continue to be supported, including C++03 compatibility).

Introduction

The purpose of Boost Exception is to ease the design of exception class hierarchies and to help write exception handling and error reporting code.

It supports transporting of arbitrary data to the catch site, which is otherwise tricky due to the no-throw requirements (15.5.1) for exception types. Data can be added to any exception object, either directly in the throw-expression (15.1), or at a later time as the exception object propagates up the call stack.

The ability to add data to exception objects after they have been passed to throw is important, because often some of the information needed to handle an exception is unavailable in the context where the failure is detected.

Boost Exception also supports N2179-style copying of exception objects, implemented non-intrusively and automatically by the boost::throw_exception function.

Contents

  1. Motivation
  2. Tutorial
  3. Documentation
  4. API
  5. Frequently Asked Questions
  6. Page Index

Acknowledgements

Thanks to Peter Dimov for his continuing help. Also thanks to Tobias Schwinger, Tom Brinkman, Pavel Vozenilek and everyone who participated in the review process.