return resp.json().then(function (json) {
          throw new Error(errorMsg + ' (' + resp.status + ' ' + resp.statusText + ') ' + JSON.stringify(json))
        }, function () {