silexlabs / unifile

Unified access to cloud storage services through a simple web API.
https://silexlabs.github.io/unifile/
MIT License
144 stars 32 forks source link

Unifile throws error instead of rejecting Promise #148

Open lexoyo opened 5 years ago

lexoyo commented 5 years ago

Hi @JbIPS

I found cases where unifile throws error instead of a "rejected" Promise

For example when you call unifile.readdir with a service which does not exist, it throws the error Error: Unknown connector: fs instead of returning Promise.reject with this same error

Am I mistaken? Is this the intended behaviour?

Thx!

JbIPS commented 5 years ago

You're right, it shouldn't. I think it's because it fails before the async call but it should be wrapped in a Promise for consistency.

lexoyo commented 5 years ago

Same for writeFile, cf CloudExplorer2 router.js file, there is a comment about that