• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1////
2Copyright 2003-2017 Beman Dawes
3Copyright 2018 Peter Dimov
4
5Distributed under the Boost Software License, Version 1.0.
6
7See accompanying file LICENSE_1_0.txt or copy at
8http://www.boost.org/LICENSE_1_0.txt
9////
10
11[#introduction]
12# Introduction
13:idprefix: intro_
14
15Error conditions originating from the operating system or other low-level
16application program interfaces (API's) are typically reported via an integer
17representing an error code. When these low-level API calls are wrapped in
18portable code, such as in a portable library, some users want to deal with the
19error codes in portable ways. Other users need to get at the system specific
20error codes, so they can deal with system specific needs. The Boost System
21library provides simple, light-weight `error_code` objects that encapsulate
22system-specific error code values, yet also provide access to more abstract
23and portable error conditions via `error_condition` objects.
24
25Because `error_code` objects can represent errors from sources other than the
26operating system, including user-defined sources, each `error_code` and
27`error_condition` has an associated `error_category`.
28
29An exception class, `system_error`, is provided. Derived from
30`std::runtime_error`, it captures the underlying `error_code` for the problem
31causing the exception so that this important information is not lost.
32
33While exceptions are the preferred {cpp} default error code reporting
34mechanism, users of libraries dependent on low-level API's often need overloads
35reporting error conditions via error code arguments and/or return values rather
36than via throwing exceptions. Otherwise, when errors are not exceptional
37occurrences and must be dealt with as they arise, programs become littered with
38try/catch blocks, unreadable, and inefficient. The Boost System library
39supports both error reporting by exception and by error code.
40
41In addition to portable errors codes and conditions supported by the
42`error_code.hpp` header, system-specific headers support the Cygwin, Linux,
43and Windows platforms. These headers are effectively no-ops if included for
44platforms other than their intended target.
45
46Boost.System is part of the {cpp}11 Standard Library.
47A number of changes, particularly to names, were made by the C++ committee
48during standardization. The Boost implementation has been tracking those changes.
49See <<#ref_deprecated_names,Deprecated Names>> for synonyms provided to prevent
50breakage of existing user code.
51