From 081bc1334dec8a1076473cc253411ab276a25f42 Mon Sep 17 00:00:00 2001 From: kapilp93 Date: Fri, 2 Aug 2024 15:36:39 +0530 Subject: [PATCH] Added TooManyRequestsException to handle 429 response status code --- lib/plivo/base_client.rb | 4 ++++ lib/plivo/exceptions.rb | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/lib/plivo/base_client.rb b/lib/plivo/base_client.rb index 50673731..cc7caf13 100644 --- a/lib/plivo/base_client.rb +++ b/lib/plivo/base_client.rb @@ -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' diff --git a/lib/plivo/exceptions.rb b/lib/plivo/exceptions.rb index e2b1f045..308067a6 100644 --- a/lib/plivo/exceptions.rb +++ b/lib/plivo/exceptions.rb @@ -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