Skip to content

Commit

Permalink
fix(error-type): Look at error type for quota
Browse files Browse the repository at this point in the history
  • Loading branch information
briansunter committed Oct 16, 2022
1 parent 1149dac commit a99b7da
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async function runOpenAI(b: IHookEvent) {
return false;
}
if (err.response.status === 429) {
const errorCode = err.response.data.error.code;
const errorCode = err.response.data.error.type;
if (errorCode === "insufficient_quota") {
return false;
}
Expand Down Expand Up @@ -113,7 +113,7 @@ async function runOpenAI(b: IHookEvent) {
console.error("OpenAI API key is invalid.");
logseq.App.showMsg("Invalid OpenAI API Key.", "error");
} else if (httpStatus === 429) {
if (errorCode === "insufficient_quota") {
if (errorType === "insufficient_quota") {
console.error(
"Exceeded OpenAI API quota. Or your trial is over. You can buy more at https://beta.openai.com/account/billing/overview"
);
Expand Down

0 comments on commit a99b7da

Please sign in to comment.