Fix SQS error handling.

This commit is contained in:
Sam Rose 2024-10-07 09:48:33 +01:00
parent 0c35345146
commit 27578db4b7
No known key found for this signature in database
1 changed files with 8 additions and 4 deletions

View File

@ -371,11 +371,15 @@ export class DatabaseImpl implements Database {
return this.performCall(() => {
return async () => {
const response = await directCouchUrlCall(args)
const json = await response.json()
if (response.status > 300) {
throw json
if (response.status >= 300) {
const text = await response.text()
console.error(`SQS error: ${text}`)
throw new CouchDBError(
"error while running SQS query, please try again later",
{ name: "sqs_error", status: response.status }
)
}
return json as T
return (await response.json()) as T
}
})
}