diff --git a/packages/rest-client/lib/fetch.js b/packages/rest-client/lib/fetch.js index ed6c5c94e1..7c5f39f0df 100644 --- a/packages/rest-client/lib/fetch.js +++ b/packages/rest-client/lib/fetch.js @@ -30,7 +30,11 @@ class FetchService extends Base { return response; } - return response.json().then(error => { + return response.json().catch(() => { + const ErrorClass = errors[response.status] || Error; + + return new ErrorClass('JSON parsing error'); + }).then(error => { error.response = response; throw error; });