[phobos] Why ConvError and not ConvException?

Jonathan M Davis jmdavisProg at gmx.com
Mon Nov 15 19:43:23 PST 2010


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


More information about the phobos mailing list