Skip to content

Commit

Permalink
Fixes #2798 adds better error message
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Jul 12, 2023
1 parent 4563019 commit cb82c96
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

### Fixed

- Fixes [#2798](https://github.com/gitkraken/vscode-gitlens/issues/2798) - Improve response from OpenAI if key used is tied to a free account
- Fixes [#2785](https://github.com/gitkraken/vscode-gitlens/issues/2785) - Remote Provider Integration URL is broken — thanks to [PR #2786](https://github.com/gitkraken/vscode-gitlens/pull/2786) by Neil Ghosh ([@neilghosh](https://github.com/neilghosh))
- Fixes [#2791](https://github.com/gitkraken/vscode-gitlens/issues/2791) - Unable to use contributors link in README.md — thanks to [PR #2792](https://github.com/gitkraken/vscode-gitlens/pull/2792) by Leo Dan Peña ([@leo9-py](https://github.com/leo9-py))
- Fixes [#2793](https://github.com/gitkraken/vscode-gitlens/issues/2793) - Requesting username change in contributors README page — thanks to [PR #2794](https://github.com/gitkraken/vscode-gitlens/pull/2794) by Leo Dan Peña ([@leo9-py](https://github.com/leo9-py))
Expand Down
14 changes: 12 additions & 2 deletions src/ai/openaiProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ export class OpenAIProvider implements AIProvider {

if (!rsp.ok) {
debugger;
throw new Error(`Unable to generate commit message: ${rsp.status}: ${rsp.statusText}`);
if (rsp.status === 429) {
throw new Error(
`Unable to generate commit message: (${this.name}:${rsp.status}) Too many requests (rate limit exceeded) or your API key is associated with an expired trial`,
);
}
throw new Error(`Unable to generate commit message: (${this.name}:${rsp.status}) ${rsp.statusText}`);
}

const data: OpenAIChatCompletionResponse = await rsp.json();
Expand Down Expand Up @@ -133,7 +138,12 @@ export class OpenAIProvider implements AIProvider {

if (!rsp.ok) {
debugger;
throw new Error(`Unable to explain commit: ${rsp.status}: ${rsp.statusText}`);
if (rsp.status === 429) {
throw new Error(
`Unable to explain commit: (${this.name}:${rsp.status}) Too many requests (rate limit exceeded) or your API key is associated with an expired trial`,
);
}
throw new Error(`Unable to explain commit: (${this.name}:${rsp.status}) ${rsp.statusText}`);
}

const data: OpenAIChatCompletionResponse = await rsp.json();
Expand Down

0 comments on commit cb82c96

Please sign in to comment.