Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

store errno in SIMPLE-FILE-ERROR conditions #442

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

galdor
Copy link

@galdor galdor commented Feb 21, 2023

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.

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 does not exist. Without this patch, it is impossible to make the
difference between a file-not-found error and for example an IO error.
@galdor
Copy link
Author

galdor commented Feb 22, 2023

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?

@xrme
Copy link
Member

xrme commented Feb 22, 2023

#364 may also be in this area

@galdor
Copy link
Author

galdor commented Feb 22, 2023

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

@xrme
Copy link
Member

xrme commented Feb 26, 2023

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.

@galdor
Copy link
Author

galdor commented Feb 28, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants