tweedegolf / storage-abstraction

Provides an abstraction layer for interacting with a storage; the storage can be local or in the cloud.
MIT License
106 stars 18 forks source link

Exceptions (lack thereof) #63

Closed granthusbands closed 5 months ago

granthusbands commented 5 months ago

The lack of exceptions has been very surprising. Exceptions are easy to work with in modern JS (especially with async/await), and being able to create broken Storage instances that quietly fail on every operation has just cost me quite a lot of debugging time. Similarly, missing a bucketName for a writeFile on a local storage adapter, even though such a thing is meaningless, has also been painful.

Is there any way to enable exceptions?

abudaan commented 5 months ago

The library deliberately doesn't throw any exceptions.

Instead all API calls resolve in a promise that returns a result object that the user (you) can check for errors. See the migration document.

The error messages are as descriptive as possible or they are passed on directly from the cloud storage service. The result objects are documented per API call in the readme.

Exceptions are to be implemented in user code (your code) so you can decide yourself whether or not the exception is blocking.