Skip to content
This repository has been archived by the owner on Nov 21, 2018. It is now read-only.

Make client return with a response object #31

Closed
roberthoner opened this issue Nov 3, 2015 · 0 comments
Closed

Make client return with a response object #31

roberthoner opened this issue Nov 3, 2015 · 0 comments
Assignees
Milestone

Comments

@roberthoner
Copy link
Contributor

I think we should stop raising exceptions for every non-20x response. Instead, we should only be raising exceptions for server errors (50x) and timeouts.

If the downstream service returns a validation error or some other 40x error, it should be up to the consuming service to handle this gracefully. The only thing it doesn't have to handle gracefully on its own are timeouts and 50x errors.

To facilitate this, the Rester::Client should return a response object like so:

responce = Service.resources(id).get

if response.successful?
  response[:key] # => access response data as hash keys.
else
  response[:error] # => type of error
  response[:message]
end
@roberthoner roberthoner added this to the 0.3.0 milestone Nov 3, 2015
@kayvonghaffari kayvonghaffari self-assigned this Nov 5, 2015
kayvonghaffari added a commit that referenced this issue Nov 9, 2015
roberthoner pushed a commit that referenced this issue Nov 10, 2015
[#31] Make client return with a response object
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants