This is an automated email from the ASF dual-hosted git repository.
glynnbird pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/couchdb-nano.git
The following commit(s) were added to refs/heads/main by this push:
new e20ffea Capture error message, otherwise capture cause of HTTP
failure (#358)
e20ffea is described below
commit e20ffea72885ae12c0224b2782ab4fde9575e126
Author: //de <[email protected]>
AuthorDate: Mon Sep 15 08:42:19 2025 -0700
Capture error message, otherwise capture cause of HTTP failure (#358)
* Capture error message, otherwise capture cause of HTTP failure
One approach to apache/couchdb-nano#356
* Comment to clarify what 'response' might be
Addressing #356 with a comment, since this is a type issue
* Improvement of performance, readability, and priority in failure case
Moving forward on #358 with a bit more aggressive change per discussion
---
lib/nano.js | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/lib/nano.js b/lib/nano.js
index c7bbda2..f21389a 100644
--- a/lib/nano.js
+++ b/lib/nano.js
@@ -122,16 +122,18 @@ module.exports = exports = function dbScope (cfg) {
}
}
- // let parsed
- const responseHeaders = Object.assign({
+ const responseHeaders = {
uri: scrubURL(req.url),
- statusCode
- }, response.headers ? response.headers : {})
+ statusCode,
+ ...(response.headers ?? {})
+ };
+
if (!response.status) {
- response.statusText = response.cause.toString()
log({ err: 'socket', body, headers: responseHeaders })
if (reject) {
- reject(new Error(`error happened in your connection. Reason:
${response.statusText}`))
+ // since #relax might have sent Error rather than Response:
+ const statusText = response.cause?.toString() ?? response.message
+ reject(new Error(`error happened in your connection. Reason:
${statusText}`))
}
return
}