ccl icon indicating copy to clipboard operation
ccl copied to clipboard

store errno in SIMPLE-FILE-ERROR conditions

Open galdor opened this issue 2 years ago • 5 comments

CCL signals SIMPLE-FILE-ERROR conditions for all file-related errors, but they do not contain any information to programmatically distinguish what the error actually is.

The most basic use case is the ability to detect that opening a file failed because it did not exist. Without this patch, it is impossible to make the difference between a file-not-found error and, for example, an IO error.

I originally wanted to introduced a new FILE-DOES-NOT-EXIST condition inheriting from SIMPLE-FILE-ERROR as SBCL does with SB-EXT:FILE-DOES-NOT-EXIST, but this would require seriously reworking the whole %ERR-DISP-COMMON thing, and I honestly have no idea where to start. Storing errno into the file error makes sense. Even if it is very low level, it provides the necessary information so that a caller can decide how to handle it, without changing any existing API.

galdor avatar Feb 21 '23 15:02 galdor

Btw I just realized that SIMPLE-FILE-ERROR was not exported. Would it be ok to export it with SIMPLE-FILE-ERROR-ERRNO, and if yes where should the export be?

galdor avatar Feb 22 '23 20:02 galdor

https://github.com/Clozure/ccl/issues/364 may also be in this area

xrme avatar Feb 22 '23 22:02 xrme

Indeed, it seems useful. But there is not much I can do about it, I do not have write access ;)

galdor avatar Feb 22 '23 23:02 galdor

I hate to discourage this, but it feels to me that this (expose errno in simple-file-error) is not the right way to go.

You said that you really wanted a file-does-not-exist error, and I'd rather see us pursue that. I see that there is a lot of hair around %err-disp and friends, and I don't blame you for wanting to look the other way.

xrme avatar Feb 26 '23 22:02 xrme

That would be better indeed; but in that case, I would simply ignore %ERR-DISP and signal the right condition directly at the source. I suspect %ERR-DISP, which seems to be only used to dispatch to the "right" condition type, could be removed altogether.

galdor avatar Feb 28 '23 11:02 galdor