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

Wrap faraday errors #177

Merged
merged 4 commits into from Oct 4, 2016
Merged

Wrap faraday errors #177

merged 4 commits into from Oct 4, 2016

Conversation

ashfire908
Copy link
Contributor

Wraps Faraday::TimeoutError and Faraday::ConnectionError with Fauna::UnavailableError. Also throws Fauna::UnavailableError for 503s even when we didn't get a valid JSON error back.

@@ -237,6 +237,8 @@ def perform_request(action, path, query, data)
req.body = FaunaJson.to_json(data) unless data.nil?
req.url(path || '')
end
rescue Faraday::ConnectionFailed, Faraday::TimeoutError => e
Copy link
Contributor

Choose a reason for hiding this comment

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

You should also rescue any Faraday::Error and throw a UnexpectedError if status is not 503.

Reference: https://github.com/faunadb/faunadb-jvm/blob/master/faunadb-java/src/main/java/com/faunadb/client/FaunaClient.java#L257

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The other two errors under Faraday::Error that we'd get are SSLError and ParsingError. I don't think we can expect a status code to be returned in either case, so I'll just raise UnavailableError for everything but ParsingError

Copy link
Contributor

@erickpintor erickpintor left a comment

Choose a reason for hiding this comment

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

LGTM

@ashfire908 ashfire908 merged commit 10293bf into master Oct 4, 2016
@ashfire908 ashfire908 deleted the wrap_faraday_errors branch October 4, 2016 17:51
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