Skip to content

Commit 484d9ae

Browse files
committed
refactor: do not overwrite the error stack in json parser
1 parent 0aa4e11 commit 484d9ae

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

lib/types/json.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ function json (options) {
7777
return JSON.parse(body, reviver)
7878
} catch (e) {
7979
throw normalizeJsonSyntaxError(e, {
80-
message: e.message,
81-
stack: e.stack
80+
message: e.message
8281
})
8382
}
8483
}
@@ -158,8 +157,7 @@ function createStrictSyntaxError (str, char) {
158157
return normalizeJsonSyntaxError(e, {
159158
message: e.message.replace(JSON_SYNTAX_REGEXP, function (placeholder) {
160159
return str.substring(index, index + placeholder.length)
161-
}),
162-
stack: e.stack
160+
})
163161
})
164162
}
165163
}
@@ -198,8 +196,6 @@ function normalizeJsonSyntaxError (error, obj) {
198196
}
199197
}
200198

201-
// replace stack before message for Node.js 0.10 and below
202-
error.stack = obj.stack.replace(error.message, obj.message)
203199
error.message = obj.message
204200

205201
return error

0 commit comments

Comments
 (0)