Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-02-09 21:13:54

"Reece Dunn" <msclrhd_at_[hidden]> wrote in message
> Jonathan Turkanis wrote:
> >To me, the ability to write an exception to a stream is
> >since you can just use what(). The ability to write to an exception
> >class using operator<< has a certain appeal; I would defintely use
> >it were free. On the other hand, if the stream operations are only
> >happening before the exception is thrown, and if you are dealing
> >an exception type that already has the ability to hold some text,
> >can get the same effect by using a stringstream. I'm not sure it's
> >worth introducing a new exception class just to save programmers
> >trouble of defining a stringstream. Maybe for use in certaint types
> >testing it would be helpful.
> Using a stringstream would be my approach to achieve this affect,
but I
> wonder what would happen if the stream operation generated an
> E.g.
> throw( std::ostringstream() << "Error #" << 404 << weberror(
404 ));
> what if weberror thows an exception? Also, is ostringstream
guaranteed not
> to throw an exception?
> Throwing an exception during the exception process is not a good

I agree. It's not as bad as letting an exception escapre from a
destructor, but it's still best avoided, since the original error
never gets reported. That's why I mentioned the exception guidlines in
my first post.

I was trying say :-) that if you decide you don't care about these
problems, in a particular usage scenario, you can essentially get
effect of overloading operator<< by just using a stringstream.

Best Regards,

Boost list run by bdawes at, gregod at, cpdaniel at, john at