Skip to content

Commit 44f2b9b

Browse files
authored
Add detailed error message (fixes issue #58) (#285)
* The mocked/unmocked tests do not exist anymore * Fixes #58: Include additional information when something fails when connecting, to support easier debugging of connection issues
1 parent ff86c94 commit 44f2b9b

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,7 @@ Everyone is welcome to contribute with patches, bug-fixes and new features.
2525
7. Push to your branch `git push origin my_branch`
2626
8. Create a pull request
2727

28-
To run tests, make sure you run `npm test` but also run tests without mocks:
29-
30-
``` sh
31-
npm run unmocked
32-
npm run mocked
33-
npm test
34-
```
28+
To run tests, make sure you run `npm test`.
3529

3630
Please fix all issues identified in the pre-commit hooks before sending your patch. if you don't, we will close the patch and ask you to re-open it once you have:
3731

lib/nano.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ module.exports = exports = function dbScope (cfg) {
134134
if (!response.status) {
135135
log({ err: 'socket', body: body, headers: responseHeaders })
136136
if (reject) {
137-
reject(new Error('error happened in your connection'))
137+
reject(new Error(`error happened in your connection. Reason: ${response.message}`))
138138
}
139139
if (callback) {
140140
const returnError = {
141-
message: 'error happened in your connection',
141+
message: `error happened in your connection. Reason: ${response.message}`,
142142
scope: 'socket',
143143
errid: 'request'
144144
}

test/nano.timeout.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ test('check requests timeout - nano.request', async () => {
3838
db: 'db',
3939
qs: { a: 1, b: 2 }
4040
}
41-
await expect(nano.request(req)).rejects.toThrow('error happened in your connection')
41+
await expect(nano.request(req)).rejects.toThrow('error happened in your connection. Reason: timeout of 500ms exceeded')
4242
})
4343

4444
test('check request timeout (callback) - nano.request', () => {

0 commit comments

Comments
 (0)