Skip to content

Commit

Permalink
Add HTTPTooManyRequestsClientException
Browse files Browse the repository at this point in the history
  • Loading branch information
andyjeffries committed Sep 18, 2019
1 parent e6154dc commit 5845016
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,11 @@
# Changelog

## 1.8.1

Features:

- Added a specific `Flexirest::HTTPTooManyRequestsClientException` for 429 errors, to enable easier trapping

## 1.8.0

Features:
Expand Down
3 changes: 3 additions & 0 deletions lib/flexirest/request.rb
Expand Up @@ -584,6 +584,8 @@ def handle_response(response, cached = nil)
raise HTTPTimeoutClientException.new(status:status, result:error_response, raw_response: @response.body, url:@url, method: http_method)
elsif status == 409
raise HTTPConflictClientException.new(status:status, result:error_response, raw_response: @response.body, url:@url, method: http_method)
elsif status == 409

This comment has been minimized.

Copy link
@tmimura39

tmimura39 Sep 29, 2019

Contributor

@andyjeffries

This is correct?
I think 429 is right.

This comment has been minimized.

Copy link
@andyjeffries

andyjeffries Sep 30, 2019

Author Collaborator

Good spot, thanks. Corrected and released as v1.8.6 (and given you credit).

raise HTTPTooManyRequestsClientException.new(status:status, result:error_response, raw_response: @response.body, url:@url, method: http_method)
elsif (400..499).include? status
raise HTTPClientException.new(status:status, result:error_response, raw_response: @response.body, url:@url, method: http_method)
elsif (500..599).include? status
Expand Down Expand Up @@ -841,6 +843,7 @@ class HTTPNotAcceptableClientException < HTTPClientException ; end
class HTTPTimeoutClientException < HTTPClientException ; end
class HTTPConflictClientException < HTTPClientException ; end
class HTTPNotFoundClientException < HTTPClientException ; end
class HTTPTooManyRequestsClientException < HTTPClientException ; end
class HTTPServerException < HTTPException ; end

end
2 changes: 1 addition & 1 deletion lib/flexirest/version.rb
@@ -1,3 +1,3 @@
module Flexirest
VERSION = "1.8.0"
VERSION = "1.8.1"
end

0 comments on commit 5845016

Please sign in to comment.