fix: handle unreachable openai.com (#100)

This commit is contained in:
hiroki osame
2023-02-22 00:16:01 -05:00
committed by GitHub
parent 13b06e8c16
commit 75d77001b1

View File

@@ -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;
}