Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 275d633

Browse files
committed
errors were impossible to parse
1 parent 8e8db33 commit 275d633

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/request-api.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ function onEnd (buffer, result, passThrough, cb) {
1515
}
1616

1717
if (res.statusCode >= 400 || !res.statusCode) {
18-
return cb(new Error(`Server responded with ${res.statusCode}: ${body}`))
18+
var error = new Error(`Server responded with ${res.statuscode}: ${body}`)
19+
body = JSON.parse(body)
20+
error.code = body.Code
21+
error.message = body.Message
22+
return cb(error)
1923
}
2024

2125
if (result.stream) {

0 commit comments

Comments
 (0)