use synchronous try/catch to fix codecov missing lines

This commit is contained in:
jared kantrowitz 2017-06-19 20:21:46 -04:00 committed by Jared Kantrowitz
parent 1804041726
commit 6b990d0631
1 changed files with 3 additions and 4 deletions

View File

@ -88,12 +88,11 @@ Body.prototype = {
*/
json() {
return consumeBody.call(this).then((buffer) => {
return JSON.parse(buffer.toString());
}).catch((err) => {
if (err instanceof SyntaxError) {
try {
return JSON.parse(buffer.toString());
} catch (err) {
return Body.Promise.reject(new FetchError(`invalid json response body at ${this.url} reason: ${err.message}`, 'invalid-json'));
}
throw err;
})
},