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 1, 2024
1 parent 1cc0af8 commit 0a54565
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Plivo/Exceptions/PlivoResponseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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?
Expand Down
14 changes: 14 additions & 0 deletions src/Plivo/Exceptions/PlivoTooManyRequestsException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Plivo\Exceptions;


/**
* Class PlivoTooManyRequestsException
* @package Plivo\Exceptions
*/

class PlivoTooManyRequestsException extends PlivoRestException
{

}

0 comments on commit 0a54565

Please sign in to comment.