@nxtedition/lib 18.0.7 → 18.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/couch.js +10 -3
- package/errors.js +1 -1
- package/package.json +1 -1
package/couch.js
CHANGED
|
@@ -245,7 +245,6 @@ export function makeCouch(opts) {
|
|
|
245
245
|
'request-id': genReqId(),
|
|
246
246
|
...(body ? { 'content-type': 'application/json' } : {}),
|
|
247
247
|
},
|
|
248
|
-
throwOnError: true,
|
|
249
248
|
highWaterMark: 256 * 1024, // TODO (fix): Needs support in undici...
|
|
250
249
|
bodyTimeout: 2 * (params.heartbeat || 60e3),
|
|
251
250
|
}
|
|
@@ -253,6 +252,14 @@ export function makeCouch(opts) {
|
|
|
253
252
|
try {
|
|
254
253
|
const res = await client.request(req)
|
|
255
254
|
|
|
255
|
+
if (res.statusCode < 200 || res.statusCode >= 300) {
|
|
256
|
+
throw makeError(req, {
|
|
257
|
+
status: res.statusCode,
|
|
258
|
+
headers: res.headers,
|
|
259
|
+
data: await res.body.text(),
|
|
260
|
+
})
|
|
261
|
+
}
|
|
262
|
+
|
|
256
263
|
retryCount = 0
|
|
257
264
|
|
|
258
265
|
let str = ''
|
|
@@ -328,7 +335,7 @@ export function makeCouch(opts) {
|
|
|
328
335
|
return await res.body.json()
|
|
329
336
|
} catch (err) {
|
|
330
337
|
Object.assign(err, { data: req })
|
|
331
|
-
|
|
338
|
+
throw err
|
|
332
339
|
}
|
|
333
340
|
}
|
|
334
341
|
|
|
@@ -356,7 +363,7 @@ export function makeCouch(opts) {
|
|
|
356
363
|
return
|
|
357
364
|
}
|
|
358
365
|
|
|
359
|
-
promise = next()
|
|
366
|
+
promise = next().catch((err) => ({ err }))
|
|
360
367
|
|
|
361
368
|
if (batched) {
|
|
362
369
|
yield results
|
package/errors.js
CHANGED
|
@@ -83,7 +83,7 @@ export function serializeError(error) {
|
|
|
83
83
|
message = msg,
|
|
84
84
|
errors,
|
|
85
85
|
code,
|
|
86
|
-
exitCode = /^([A-Z]+|[a-z]+|[0-9]+)$/.test(code) ? code :
|
|
86
|
+
exitCode = /^([A-Z]+|[a-z]+|[0-9]+)$/.test(code) ? code : undefined,
|
|
87
87
|
signal,
|
|
88
88
|
signalCode = signal,
|
|
89
89
|
cause,
|