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 ca5817b commit 8201f0c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/rest/axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export function Axios(config) {
404: Exceptions.ResourceNotFoundError,
405: Exceptions.InvalidRequestError,
406: Exceptions.NotAcceptableError,
429: Exceptions.TooManyRequestsError,
500: Exceptions.ServerError,
} [response.status] || Error;

Expand Down Expand Up @@ -105,6 +106,7 @@ export function Axios(config) {
404: Exceptions.ResourceNotFoundError,
405: Exceptions.InvalidRequestError,
406: Exceptions.NotAcceptableError,
429: Exceptions.TooManyRequestsError,
500: Exceptions.ServerError,
} [error.response.status] || Error;
if (!_.inRange(error.response.status, 200, 300)) {
Expand Down Expand Up @@ -258,6 +260,7 @@ export function Axios(config) {
500: Exceptions.ServerError,
409: Exceptions.InvalidRequestError,
422: Exceptions.InvalidRequestError,
429: Exceptions.TooManyRequestsError,
207: Exceptions.InvalidRequestError,
} [response.status] || Error;

Expand Down Expand Up @@ -295,6 +298,7 @@ export function Axios(config) {
500: Exceptions.ServerError,
409: Exceptions.InvalidRequestError,
422: Exceptions.InvalidRequestError,
429: Exceptions.TooManyRequestsError,
207: Exceptions.InvalidRequestError,
} [error.response.status] || Error;
if (!_.inRange(error.response.status, 200, 300)) {
Expand Down
1 change: 1 addition & 0 deletions lib/rest/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export function Request(config) {
401: Exceptions.AuthenticationError,
404: Exceptions.ResourceNotFoundError,
405: Exceptions.InvalidRequestError,
429: Exceptions.TooManyRequestsError,
500: Exceptions.ServerError,
} [response.statusCode] || Error;

Expand Down
3 changes: 2 additions & 1 deletion lib/utils/exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export class InvalidRequestError extends PlivoRestError { }
export class PlivoXMLError extends PlivoRestError { }
export class PlivoXMLValidationError extends PlivoRestError { }
export class AuthenticationError extends PlivoRestError { }
export class NotAcceptableError extends PlivoRestError { }
export class NotAcceptableError extends PlivoRestError { }
export class TooManyRequestsError extends PlivoRestError { }

0 comments on commit 8201f0c

Please sign in to comment.