Skip to content

Commit

Permalink
* Expose the Rate limit error retryAfter time in the error object
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollon77 committed Jul 5, 2024
1 parent 01aabdd commit 173720f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ See [`src/example.ts`](./src/example.ts).
* Add Tests

## Changelog:
### 2.1.0 (2024-07-05)
### __WORK IN PROGRESS__
* Expose the Rate limit error retryAfter time in the error object

### 2.0.0 (2024-07-05)
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface DaikinCloudControllerEvents {
}

export class RateLimitedError extends Error {
constructor(message: string, public retryAfter: number) {
constructor(message: string, public retryAfter?: number) {
super(message);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/onecta/oidc-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export class OnectaClient {
throw new Error(`Unprocessable Entity (422): ${res.body ? res.body.toString() : 'No body response from the API'}`);
case 429: {
// See "Rate limitation" at https://developer.cloud.daikineurope.com/docs/b0dffcaa-7b51-428a-bdff-a7c8a64195c0/general_api_guidelines
const retryAfter = res.headers['retry-after'];
const retryAfter = maybeParseInt(res.headers['retry-after']);
throw new RateLimitedError(`API request rate-limited, retry after ${retryAfter} seconds`, retryAfter);
}
case 500:
Expand Down

0 comments on commit 173720f

Please sign in to comment.