Skip to content

Commit

Permalink
Added TooManyRequestsException to handle 429 response status code
Browse files Browse the repository at this point in the history
  • Loading branch information
kapilp93 committed Aug 2, 2024
1 parent ae7e38f commit 081bc13
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/plivo/base_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@ def handle_response_exceptions(response)
Exceptions::InvalidRequestError,
'Unprocessable Entity'
],
429 => [
Exceptions::TooManyRequestsError,
'Too many requests'
],
500 => [
Exceptions::PlivoServerError,
'A server error occurred while accessing resource'
Expand Down
6 changes: 6 additions & 0 deletions lib/plivo/exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,11 @@ module Exceptions
##
# This will be raised when there is an authentication error
ResourceNotFoundError = Class.new(PlivoRESTError)

##
# This will be raised when the API calls to the server reach their limit.
#
# Usually, the reason why this error is raised will be included.
TooManyRequestsError = Class.new(PlivoRESTError)
end
end

0 comments on commit 081bc13

Please sign in to comment.