exceptions [C++ Reference]
Keywords: io,exceptions
Date: 2008-10-14T15:42:04-0700

[[exceptions]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- cz
- de
- es
- fr
- it
- jp
- nl
- pl
- ro
- ru
- sk
- tr
- tw

## exceptions

Sets the stream to throw exceptions instead of silently ignoring the error conditions specified. Without parameters returns the current setting.

The setting is composed by ORing together bits for the conditions to throw on. The following code enables all exceptions on stream s.

       s.exceptions(std::ios::badbit | std::ios::failbit | std::ios::eofbit);

Related Topics: bad, clear, eof, fail, good, rdstate

Stream states:

- if (s): The previous operation was successful (a shorthand for !s.fail()).
- if (s.fail()): The previous operation failed.
- if (s.eof()): Reading past the end has been attempted.
- if (s.bad()): Stream state is undefined; the stream can no longer be used.
- if (s.good()): None of bad/eof/fail are set.

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •