Template:cpp/io/stream exceptions

failure if an error occurred (the error state flag is not goodbit) and exceptions is set to throw for that state.

If an internal operation throws an exception, it is caught and badbit is set. If exceptions is set for, the exception is rethrown.