[phobos] Why ConvError and not ConvException?

Andrei Alexandrescu andrei at erdani.com
Mon Nov 15 19:44:50 PST 2010


Historical reasons. I favor your implied change.

Andrei

On 11/15/10 7:43 PM, Jonathan M Davis wrote:
> Why is ConvError in std.conv (which is used for to!() on conversion failure) an
> Error rather than an Exception? I would have expected it to be an Exception. And
> the fact that it's an Error makes it so that you can't cleanly call to!() and
> catch an exception on failure and then deal with the fact that it failed. For
> instance, if it wer an Exception and you had an string which was supposedly an
> enum value for the enum MyEnum, you could do to!MyEnum(str), catch the Exception
> on failure, and do whatever was appropriate given that it's not a valid MyEnum.
> But with it being an Error, you can't do that (unless you're willing to catch an
> Error which is not supposed to be done). Am I missing something here?
>
> - Jonathan M Davis
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos


More information about the phobos mailing list