The current api makes no attempt (as far as I can tell) to distinguish deterministic expected failure modes (e.g. attempting to read a file that does not exist) from others (e.g. transient network errors).
For example, FileStorage.read will simply throw an UnableToReadFile error regardless of what caused it.
https://github.com/duna-oss/flystorage/blob/91b53f337188871d845b1c2ced474df96eac17bd/packages/file-storage/src/file-storage.ts#L189-L198
It would be appropriate to introduce error codes so that consuming code can decide how to handle different conditions, and various implementations of StorageAdapter would have to abide by the rules and transform upstream errors appropriately. While one could call FileStorage.fileExists first to check if a file exists, that is insufficient in the general case, as a file could be deleted in the backing storage between the call to fileExists and the subsequent read.
I really like the simplistic api that flystorage provides, and tackling this would make it appealing in even more applications. Thanks!
The current api makes no attempt (as far as I can tell) to distinguish deterministic expected failure modes (e.g. attempting to read a file that does not exist) from others (e.g. transient network errors).
For example,
FileStorage.readwill simply throw anUnableToReadFileerror regardless of what caused it.https://github.com/duna-oss/flystorage/blob/91b53f337188871d845b1c2ced474df96eac17bd/packages/file-storage/src/file-storage.ts#L189-L198
It would be appropriate to introduce error codes so that consuming code can decide how to handle different conditions, and various implementations of StorageAdapter would have to abide by the rules and transform upstream errors appropriately. While one could call
FileStorage.fileExistsfirst to check if a file exists, that is insufficient in the general case, as a file could be deleted in the backing storage between the call tofileExistsand the subsequentread.I really like the simplistic api that
flystorageprovides, and tackling this would make it appealing in even more applications. Thanks!