handle error objects from lbryweb

This commit is contained in:
Sean Yesmunt 2019-03-15 12:16:33 -04:00
parent f140db38dd
commit 2a7e05940f
2 changed files with 8 additions and 4 deletions

9
dist/bundle.js vendored
View file

@ -2171,10 +2171,12 @@ Object.defineProperty(exports, "__esModule", {
value: true value: true
}); });
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; // @flow
__webpack_require__(10); __webpack_require__(10);
var CHECK_DAEMON_STARTED_TRY_NUMBER = 200; // @flow var CHECK_DAEMON_STARTED_TRY_NUMBER = 200;
var Lbry = { var Lbry = {
isConnected: false, isConnected: false,
@ -2189,7 +2191,8 @@ function checkAndParse(response) {
return response.json().then(function (json) { return response.json().then(function (json) {
var error = void 0; var error = void 0;
if (json.error) { if (json.error) {
error = new Error(json.error); var errorMessage = _typeof(json.error) === 'object' ? json.error.message : json.error;
error = new Error(errorMessage);
} else { } else {
error = new Error('Protocol error with unknown response signature'); error = new Error('Protocol error with unknown response signature');
} }

View file

@ -16,7 +16,8 @@ function checkAndParse(response) {
return response.json().then(json => { return response.json().then(json => {
let error; let error;
if (json.error) { if (json.error) {
error = new Error(json.error); const errorMessage = typeof json.error === 'object' ? json.error.message : json.error;
error = new Error(errorMessage);
} else { } else {
error = new Error('Protocol error with unknown response signature'); error = new Error('Protocol error with unknown response signature');
} }