joshuef / safe-js

12 stars 7 forks source link

safeNFS.getDir('/') while unauthorised doesn't provide useful error handling #22

Open happybeing opened 7 years ago

happybeing commented 7 years ago

I'm not sure if this is a bug or current design, but I've been using both beaker 0.4.2 and 0.4.3-2, and also with and without the polyfill. Error object passed to the reject promise handler following safeNFS().getDir() appears to be either a string (e.g. "Unauthorized" or "Failed to fetch" etc.), or can be an object which I don't recognise, but has a message string in it (though not ones that seem relevant).

I am not sure what the intended behaviour is - I think 0.4.3-2 returns the object which doesn't seem to be useful at all (no status, no relevant message etc.) so I think that this is a bug. I don't know if it affects any other APIs.

Ideally the reject handler would receive an object with both an HTTP response type statusCode, and a useful text message. I don't see this in any situation at the moment.

happybeing commented 7 years ago

I think I tend see different kinds of object (string v object that doesn't seem useful) depending on whether I'm using the polyfill. For got to mention that - I think the polyfill returns a string that makes sense, but is not ideal on its own.