Skip to content

Commit 960e1f1

Browse files
committed
improve claude web error prompt
1 parent 4642997 commit 960e1f1

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/services/clients/claude/index.mjs

+14-2
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export class Claude {
188188
async init() {
189189
const organizations = await this.getOrganizations()
190190
if (organizations.error) {
191-
throw new Error(JSON.stringify(organizations, null, 2))
191+
throw new Error(organizations.error)
192192
}
193193
this.organizationId = organizations[0].uuid
194194
this.recent_conversations = await this.getConversations()
@@ -222,7 +222,19 @@ export class Claude {
222222
cookie: `sessionKey=${this.sessionKey}`,
223223
},
224224
})
225-
return await response.json().catch(errorHandle('getOrganizations'))
225+
const responseText = await response.text()
226+
if (responseText.includes('available in certain regions'))
227+
return {
228+
error: 'Claude.ai is not available in your region',
229+
}
230+
try {
231+
return JSON.parse(responseText)
232+
} catch (e) {
233+
errorHandle('getOrganizations')(e)
234+
return {
235+
error: 'failed to parse response',
236+
}
237+
}
226238
}
227239
/**
228240
* Delete all conversations

0 commit comments

Comments
 (0)