This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Tighten length error check in string::replace


On Thu, Apr 25, 2002 at 09:20:53PM +0200, Paolo Carlini wrote:
> >testcase?
> >
> Yes...
> Indeed, it turned out to be much more interesting than the fix itself, 
> in that a length_error may be thrown in many different places for many 
> different reasons.
> 
> I'm not much into exception handling :-(, therefore if you can think of 
> something appreciably simpler don't hesitate to point it out!

When I cleaned up and doc'd std_bitset.h, I added some explanatory text
to the messages in the exceptions.  Previously they were all "bitset"
which IMHO isn't very helpful to the end user.

So for example, if we know that the code contains

    __throw_length_error("basic_string::replace -- foo, bar, baz, blah");

then the testcase might be able to catch an exception and verify that

    ex.what() == "basic_string::replace -- foo, bar, baz, blah"

This would distinguish it from all the other length_error instances.


Phil

-- 
If ye love wealth greater than liberty, the tranquility of servitude greater
than the animating contest for freedom, go home and leave us in peace.  We seek
not your counsel, nor your arms.  Crouch down and lick the hand that feeds you;
and may posterity forget that ye were our countrymen.            - Samuel Adams


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]