Closed rrthomas closed 9 years ago
Copy/paste error? :D
Oops. Fixed, thanks!
Two things here:
More precisely, why do we handle ENOENT like this at all? We take an exception and turn it into another exception…what's the point?
This is an abstraction layer, the way we present to the user that a file was not found, for example, should be presented in a uniform way; independent of the abstracted matter. The user shouldn't bother with all the different ways the abstracted API can tells us about the state of an operation. Check the BrowserRest API how a file not found looks there.
I would put it like this: from an application perspective; when it is desirable to react on a certain kind of error; I'd like to be able to do this the same way, regardless what the abstracted file system is. IONoEntry is such an error: I may wan't to try
to open it without checking before if the file exists, because I can handle the error in case it doesn't exists.
Other errors where it might be desirable for an application to handle the errors should be the same for all abstracted interfaces.
I can think of errors where it may be better to handle it somewhere else, for example, a permission problem is usually not handled by the application directly, that's rather a thing the administrator/superuser/user of the file system should handle; by either changing the permissions or by pointing the application to a location where the permissions are sufficient.
OK, I finally understood; sorry: the API we present is not just the file API: the "intersection" of the REST and file APIs is not a strict subset of either. So, I can use the docstrings in _base.js
to see what the methods should do (currently, only IONoEntry is mentioned).
See https://github.com/rrthomas/ufoJS/commit/8edfa4739b39fdb728eb7506455562974f86ece9
We should use _callbackFactory, and raise IONoEntry.