Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: link OpenAI status on 500 error #121

Merged
merged 1 commit into from
Mar 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/utils/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ const createCompletion = (
|| response.statusCode < 200
|| response.statusCode > 299
) {
return reject(new Error(`HTTP status code ${response.statusCode}`));
let errorMessage = `OpenAI API Error: ${response.statusCode} - ${response.statusMessage}`;
if (response.statusCode === 500) {
errorMessage += '; Check the API status: https://status.openai.com';
}

return reject(new Error(errorMessage));
}

const body: Buffer[] = [];
Expand Down Expand Up @@ -88,7 +93,6 @@ export const generateCommitMessage = async (
throw new Error(`Error connecting to ${errorAsAny.hostname} (${errorAsAny.syscall}). Are you connected to the internet?`);
}

errorAsAny.message = `OpenAI API Error: ${errorAsAny.message} - ${errorAsAny.response.statusText}`;
throw errorAsAny;
}
};