From 0a545653342d71702bf25ea7e7dc7412b801bb74 Mon Sep 17 00:00:00 2001 From: kapilp93 Date: Thu, 1 Aug 2024 16:23:07 +0530 Subject: [PATCH] Added TooManyRequestsException to handle 429 response status code --- src/Plivo/Exceptions/PlivoResponseException.php | 9 ++++++++- .../Exceptions/PlivoTooManyRequestsException.php | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/Plivo/Exceptions/PlivoTooManyRequestsException.php diff --git a/src/Plivo/Exceptions/PlivoResponseException.php b/src/Plivo/Exceptions/PlivoResponseException.php index 42b1e32c..488cf0f2 100644 --- a/src/Plivo/Exceptions/PlivoResponseException.php +++ b/src/Plivo/Exceptions/PlivoResponseException.php @@ -58,7 +58,7 @@ public function getErrorMessage() /** * Returns an exceptions with a message based on the status code * @param string $message - * @return PlivoAuthenticationException|PlivoNotFoundException|PlivoRequestException|PlivoRestException|PlivoServerException|PlivoValidationException + * @return PlivoAuthenticationException|PlivoNotFoundException|PlivoRequestException|PlivoRestException|PlivoServerException|PlivoValidationException|PlivoTooManyRequestsException */ public function getException($message) { @@ -93,6 +93,13 @@ public function getException($message) new PlivoRequestException( "HTTP method used is not allowed to access resource"); break; + case 429: + return + $message? + new PlivoTooManyRequestsException($message): + new PlivoTooManyRequestsException( + "Too many requests"); + break; case 500: return $message? diff --git a/src/Plivo/Exceptions/PlivoTooManyRequestsException.php b/src/Plivo/Exceptions/PlivoTooManyRequestsException.php new file mode 100644 index 00000000..98c20f2a --- /dev/null +++ b/src/Plivo/Exceptions/PlivoTooManyRequestsException.php @@ -0,0 +1,14 @@ +