Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When we try to save/update an object, we should return an error statu… #22

Merged
merged 1 commit into from
Jan 4, 2016

Conversation

sringling
Copy link
Contributor

…s code instead of an exception if the server throws

…s code instead of an exception if the server throws
@@ -72,6 +76,9 @@ def method_missing(method, *args, &block)
else
super
end

rescue JsonApiClient::Errors::ServerError => e
pretty_error e
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

save, update_attributes, and the instance-level method_missing should all catch ServerError and return status codes like find and where do, instead of the exception coming through. Then we can use respondable classes to act on this from metadata instead of catching this exception everywhere in applications.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you foresee any other exceptions here we may want to catch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

json_api_client returns ServerError for every 500 series code from the server, so it should be OK. I guess we really want to catch StandardError here and in querayble, but so far it has not been a problem.

bluetwin pushed a commit that referenced this pull request Jan 4, 2016
When we try to save/update an object, we should return an error statu…
@bluetwin bluetwin merged commit eddbe17 into avvo:master Jan 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants