Error derived from Exception is WRONG, DAMNIT

Robert Fraser fraserofthenight at gmail.com
Sun Mar 2 15:56:36 PST 2008


downs wrote:
> Janice Caron wrote:
>> On 02/03/2008, Yigal Chripun <yigal100 at gmail.com> wrote:
>>>  Errors should
>>>  represent unrecoverable situations
>> It is important that programs that work in Debug mode should also work
>> in Release mode. For example: an ArrayBoundsException is not thrown in
>> Release mode, therefore, it should not be catchable in Debug mode.
>>
>> However, I don't think that making a distinction between Error and
>> Exception is the way to go here. I think a better way would be for
>> ArrayBoundsException to be defined in Phobos as:
>>
>>     debug class ArrayBoundsException : Exception
>>
>> That way, if you try to catch one, it will be a /compile-time/ error
>> when you compile your release build.
>>
> 
> Yeah, but if you simply catch  _all_ exceptions, the compiler will never notice the mistake and the program will still crash.
> I like the idea in principle, but it would probably work better like this
> 
> debug {
> 	class DebugModeException : Object { } // WAS Error
> 	class Exception : DebugModeException { }
> } else {
> 	class Exception : Object { }
> }
> 
>  --feep

I limes.



More information about the Digitalmars-d mailing list