improve claude web error prompt

This commit is contained in:
josc146
2024-08-07 21:13:00 +08:00
parent 464299777c
commit 960e1f1610
+14 -2
View File
@@ -188,7 +188,7 @@ export class Claude {
async init() {
const organizations = await this.getOrganizations()
if (organizations.error) {
throw new Error(JSON.stringify(organizations, null, 2))
throw new Error(organizations.error)
}
this.organizationId = organizations[0].uuid
this.recent_conversations = await this.getConversations()
@@ -222,7 +222,19 @@ export class Claude {
cookie: `sessionKey=${this.sessionKey}`,
},
})
return await response.json().catch(errorHandle('getOrganizations'))
const responseText = await response.text()
if (responseText.includes('available in certain regions'))
return {
error: 'Claude.ai is not available in your region',
}
try {
return JSON.parse(responseText)
} catch (e) {
errorHandle('getOrganizations')(e)
return {
error: 'failed to parse response',
}
}
}
/**
* Delete all conversations