Update error response and logs

This commit is contained in:
Pawan Osman
2024-04-22 14:01:24 +03:00
committed by GitHub
parent d9a36a890d
commit 46043c6851
+4 -20
View File
@@ -236,11 +236,14 @@ async function handleChatCompletion(req: Request, res: Response) {
let session = await getNewSession(); let session = await getNewSession();
if (!session) { if (!session) {
console.error("Error getting a new session...");
console.error("If this error persists, your country may not be supported yet.");
console.error("If your country was the issue, please consider using a U.S. VPN or a U.S. residential proxy.");
res.write( res.write(
JSON.stringify({ JSON.stringify({
status: false, status: false,
error: { error: {
message: `Error getting a new session, please try again later, if the issue persists, please open an issue on the GitHub repository, https://github.com/PawanOsman/ChatGPT`, message: `Error getting a new session, If this error persists, your country may not be supported yet. If your country was the issue, please consider using a U.S. VPN or a U.S. residential proxy.`,
type: "invalid_request_error", type: "invalid_request_error",
}, },
support: "https://discord.pawan.krd", support: "https://discord.pawan.krd",
@@ -596,23 +599,4 @@ app.listen(port, async () => {
console.log( console.log(
`💖 Don't forget to star the repository if you like this project!` `💖 Don't forget to star the repository if you like this project!`
); );
console.log();
setTimeout(async () => {
while (true) {
try {
await getNewSession();
await wait(refreshInterval);
} catch (error) {
console.error("Error refreshing session ID, retrying in 2 minute...");
console.error(
"If this error persists, your country may not be supported yet."
);
console.error(
"If your country was the issue, please consider using a U.S. VPN."
);
await wait(errorWait);
}
}
}, 0);
}); });