K
Kevin Saff
I would like to be able to create a std::exception from a user-defined
stream, like:
error << "Error: " << filename_ << " not found!" << std::endl;
I figured I would just create a simple streambuf that would store characters
in a string until it received '\n' and then throw a std::exception with the
contents of the string. However, this exception is caught in the stream
implementation and translated into a badbit.
Any suggestions on how to do this? Do I just need to avoid deriving from
ostream and streambuf, and create a class with its own op <<?
stream, like:
error << "Error: " << filename_ << " not found!" << std::endl;
I figured I would just create a simple streambuf that would store characters
in a string until it received '\n' and then throw a std::exception with the
contents of the string. However, this exception is caught in the stream
implementation and translated into a badbit.
Any suggestions on how to do this? Do I just need to avoid deriving from
ostream and streambuf, and create a class with its own op <<?