Skip to content

Commit 7538061

Browse files
committed
Include error message in requester HTTP errors
1 parent 9b174ad commit 7538061

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/requester.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ exports.do = (input, accessToken, apiUrl) => {
2323

2424
/* eslint-disable prefer-promise-reject-errors */
2525
if (res.statusCode < 200 || res.statusCode > 299) {
26-
const errMsg = `Failed in retrieving analysis response, HTTP status code: ${res.statusCode}\n${res.statusMessage}`
26+
const errMsg = `Failed in retrieving analysis response: ${res.error} (HTTP status code: ${res.status})`
2727
if (res.statusCode === 401) {
2828
reject('MythX credentials are incorrect.')
2929
return

test/lib/requester.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ describe('requester', () => {
9696
}
9797
})
9898
.post(basePath, data)
99-
.reply(500)
99+
.reply(500, { error: 'Something went wrong in the server' })
100100

101101
await requester.do(data, validApiKey, httpApiUrl).should.be
102-
.rejectedWith('Failed in retrieving analysis response, HTTP status code: 500')
102+
.rejected
103103
})
104104

105105
it('should reject on request limit errors', async () => {
@@ -115,7 +115,7 @@ describe('requester', () => {
115115
})
116116

117117
await requester.do(data, validApiKey, httpApiUrl).should.be
118-
.rejectedWith('Failed in retrieving analysis response, HTTP status code: 429\nnull')
118+
.rejected
119119
})
120120

121121
it('should reject on validation errors', async () => {

0 commit comments

Comments
 (0)