Skip to content

Commit dd6306e

Browse files
committed
fix: parse JSON from GitHub error messages
BREAKING CHANGE: error.message is no longer a JSON string containing GitHub’s error message. Instead the JSON is parsed internally and error properties are assigned with its value. This is not technically a breaking change but a bug fix, but as this bug was around for a long time and plenty of apps depend on `JSON.parse(error.message)` to be working, we treat it as a breaking change by way of precaution
1 parent 69a212f commit dd6306e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/request/request.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ function request (requestOptions) {
9999

100100
.catch(error => {
101101
if (error instanceof HttpError) {
102+
try {
103+
Object.assign(error, JSON.parse(error.message))
104+
} catch (_error) {
105+
// ignore, see #684
106+
}
107+
102108
throw error
103109
}
104110

0 commit comments

Comments
 (0)