Skip to content

Commit cb82c96

Browse files
committed
Fixes #2798 adds better error message
1 parent 4563019 commit cb82c96

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
2424

2525
### Fixed
2626

27+
- Fixes [#2798](https://github.com/gitkraken/vscode-gitlens/issues/2798) - Improve response from OpenAI if key used is tied to a free account
2728
- 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))
2829
- 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))
2930
- 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))

src/ai/openaiProvider.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ export class OpenAIProvider implements AIProvider {
7676

7777
if (!rsp.ok) {
7878
debugger;
79-
throw new Error(`Unable to generate commit message: ${rsp.status}: ${rsp.statusText}`);
79+
if (rsp.status === 429) {
80+
throw new Error(
81+
`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`,
82+
);
83+
}
84+
throw new Error(`Unable to generate commit message: (${this.name}:${rsp.status}) ${rsp.statusText}`);
8085
}
8186

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

134139
if (!rsp.ok) {
135140
debugger;
136-
throw new Error(`Unable to explain commit: ${rsp.status}: ${rsp.statusText}`);
141+
if (rsp.status === 429) {
142+
throw new Error(
143+
`Unable to explain commit: (${this.name}:${rsp.status}) Too many requests (rate limit exceeded) or your API key is associated with an expired trial`,
144+
);
145+
}
146+
throw new Error(`Unable to explain commit: (${this.name}:${rsp.status}) ${rsp.statusText}`);
137147
}
138148

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

0 commit comments

Comments
 (0)