pachadotdev / analogsea

Digital Ocean R client
https://pacha.dev/analogsea/
Apache License 2.0
155 stars 24 forks source link

Return user friendly error messages #5

Closed karthik closed 10 years ago

karthik commented 10 years ago

instead of a list. When I have no running droplets:

> do_droplets_get()
$status
[1] "OK"

$droplets
list()
hadley commented 10 years ago

Probably should return $droplets - I think it's reasonable to return a list of length 0 when you have no running droplets.

sckott commented 10 years ago

Okay, so return $droplets and perhaps a message stating no droplets ?

hadley commented 10 years ago

I don't think you should have any message.

hadley commented 10 years ago

In fact, I think the general pattern for all API functions should be that do_GET() handles the status message (if needed), and the API function only returns the component of the list that's actually informative.

sckott commented 10 years ago

Okay, no message it is

karthik commented 10 years ago

In fact, I think the general pattern for all API functions should be that do_GET() handles the status message (if needed), and the API function only returns the component of the list that's actually informative.

I agree here and an list of len 0 sounds fine by me. I don't disagree here. In general I agree that API calls should return easy to parse (in R) objects and I can imagine one can check to see if droplets are running and act accordingly (either kill or spin up more). But in the spirit of returning user friendly error messages and warnings (quite like asserthat), returning $droplets is better than the current return object.