Program logic bugs vs input/environmental errors

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Mon Sep 29 04:53:05 PDT 2014


On 9/29/2014 4:47 AM, Steven Schveighoffer wrote:
> On 9/27/14 9:52 PM, Walter Bright wrote:
>> On 9/27/2014 6:24 PM, Steven Schveighoffer wrote:
>>> On 9/27/14 7:15 PM, Walter Bright wrote:
>>>
>>>> When I say "They are NOT for debugging programs", I mean they are NOT
>>>> for debugging programs.
>>>
>>> Library code often cannot make that choice.
>>> The issue with exceptions vs. errors
>>> is that often you don't know where the input comes from.
>>>
>>> e.g.:
>>>
>>> auto f = File(someInternalStringThatIsCorrupted) -> error
>>> auto f = File(argv[1]) -> exception
>>>
>>> How does File know what it's target file name came from?
>>
>> If the app is concerned about invalid filenames as bugs, you should
>> scrub the filenames first. I.e. the interface is defined improperly if
>> the code confuses a programming bug with input errors.
>
> OK, so if you want to avoid improperly having errors/exceptions, don't put bugs
> into your code.
>
> A simple plan!

Validating user input is not the same thing as removing all the logic bugs from 
the program.



More information about the Digitalmars-d mailing list