Program logic bugs vs input/environmental errors

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Mon Sep 29 04:51:08 PDT 2014


On 9/28/14 5:01 AM, Jacob Carlborg wrote:
> On 2014-09-28 03:24, Steven Schveighoffer wrote:
>
>> 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?
>
> Both of theses should throw an exception. Most stuff related to file
> operations should throw an exception, not an error.
>

That makes no sense. The opening of the file is subject to issues with 
the filesystem, which means they may be environmental or user errors, 
not programming errors. But that doesn't mean the opening of the file 
failed because the file doesn't exist, it could be an error in how you 
construct the file name.

What about:

File f;
f.open(null);

Is that an environmental error or User error?

-Steve


More information about the Digitalmars-d mailing list