Adding error field.

This commit is contained in:
mike12345567 2024-05-10 11:51:57 +01:00 committed by Sam Rose
parent f036776a90
commit c9ec06b5b1
No known key found for this signature in database
1 changed files with 6 additions and 9 deletions

View File

@ -43,8 +43,9 @@ class CouchDBError extends Error {
statusCode: number
reason: string
name: string
errid: string | undefined
description: string | undefined
errid: string
error: string
description: string
constructor(
message: string,
@ -54,6 +55,7 @@ class CouchDBError extends Error {
errid: string
description: string
reason: string
error: string
}
) {
super(message)
@ -63,6 +65,7 @@ class CouchDBError extends Error {
this.name = info.name
this.errid = info.errid
this.description = info.description
this.error = info.error
}
}
@ -168,13 +171,7 @@ export class DatabaseImpl implements Database {
return await this.performCall(call)
}
// stripping the error down the props which are safe/useful, drop everything else
throw new CouchDBError(`CouchDB error: ${err.message}`, {
status: err.status || err.statusCode,
name: err.name,
errid: err.errid,
description: err.description,
reason: err.reason,
})
throw new CouchDBError(`CouchDB error: ${err.message}`, err)
}
}