Skip to content

Commit

Permalink
fix: handle unreachable openai.com (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber authored Feb 22, 2023
1 parent 13b06e8 commit 75d7700
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/utils/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export const generateCommitMessage = async (
);
} catch (error) {
const errorAsAny = error as any;
if (errorAsAny.code === 'ENOTFOUND') {
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;
}
Expand Down

0 comments on commit 75d7700

Please sign in to comment.