pachadotdev / analogsea

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

Improvements to `do_handle` #4

Closed hadley closed 10 years ago

hadley commented 10 years ago

This is untested, but:

do_GET <- function(path, query = NULL, ...) {
  url <- file.path("https://api.digitalocean.com/v1/", path)
  query <- modifyList(list(client_id = au$id, api_key = au$key), query)

  tt <- GET(url, query = query, ...)
  stop_for_status(tt)
  res <- content(tt, as = "text")
  fromJSON(res, FALSE)
}

Should also parsing for DO error messages (i.e. instead of stop_for_status() write something custom).

sckott commented 10 years ago

Thanks @hadley - I'll update with your suggestions. I do use warn_for_status instead of stop_for_status, but yeah, will write something better

sckott commented 10 years ago

Ah I see you said better to stop than warn. I have been leaning towards warn in other pkgs so that when a fxn is used in a loop or apply type fxn, the process isn't stopped (users could handle that themselves, but most probably wouldn't know how). But for this package, yeah stop instead of warning make sense