mirror of https://github.com/status-im/web3.js.git
display un parseable string, on Invlaid JSON RPC response error
This commit is contained in:
parent
ccc4331d98
commit
7be511e51f
|
@ -2075,7 +2075,7 @@ module.exports = {
|
|||
return new Error('Providor not set or invalid');
|
||||
},
|
||||
InvalidResponse: function (result){
|
||||
var message = !!result && !!result.error && !!result.error.message ? result.error.message : 'Invalid JSON RPC response';
|
||||
var message = !!result && !!result.error && !!result.error.message ? result.error.message : 'Invalid JSON RPC response: '+ result;
|
||||
return new Error(message);
|
||||
}
|
||||
};
|
||||
|
@ -3353,7 +3353,7 @@ HttpProvider.prototype.send = function (payload) {
|
|||
try {
|
||||
result = JSON.parse(result);
|
||||
} catch(e) {
|
||||
throw errors.InvalidResponse(result);
|
||||
throw errors.InvalidResponse(request.responseText);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -3369,7 +3369,7 @@ HttpProvider.prototype.sendAsync = function (payload, callback) {
|
|||
try {
|
||||
result = JSON.parse(result);
|
||||
} catch(e) {
|
||||
error = errors.InvalidResponse(result);
|
||||
error = errors.InvalidResponse(request.responseText);
|
||||
}
|
||||
|
||||
callback(error, result);
|
||||
|
@ -3583,7 +3583,7 @@ var IpcProvider = function (path, net) {
|
|||
clearTimeout(_this.lastChunkTimeout);
|
||||
_this.lastChunkTimeout = setTimeout(function(){
|
||||
_this.timeout();
|
||||
throw errors.InvalidResponse(result);
|
||||
throw errors.InvalidResponse(data);
|
||||
}, 1000 * 15);
|
||||
|
||||
return;
|
||||
|
@ -3666,12 +3666,12 @@ IpcProvider.prototype.send = function (payload) {
|
|||
if(!this.connection.writable)
|
||||
this.connection.connect({path: this.path});
|
||||
|
||||
var result = this.connection.writeSync(JSON.stringify(payload));
|
||||
var data = this.connection.writeSync(JSON.stringify(payload));
|
||||
|
||||
try {
|
||||
result = JSON.parse(result);
|
||||
result = JSON.parse(data);
|
||||
} catch(e) {
|
||||
throw errors.InvalidResponse(result);
|
||||
throw errors.InvalidResponse(data);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -2075,7 +2075,7 @@ module.exports = {
|
|||
return new Error('Providor not set or invalid');
|
||||
},
|
||||
InvalidResponse: function (result){
|
||||
var message = !!result && !!result.error && !!result.error.message ? result.error.message : 'Invalid JSON RPC response';
|
||||
var message = !!result && !!result.error && !!result.error.message ? result.error.message : 'Invalid JSON RPC response: '+ result;
|
||||
return new Error(message);
|
||||
}
|
||||
};
|
||||
|
@ -3353,7 +3353,7 @@ HttpProvider.prototype.send = function (payload) {
|
|||
try {
|
||||
result = JSON.parse(result);
|
||||
} catch(e) {
|
||||
throw errors.InvalidResponse(result);
|
||||
throw errors.InvalidResponse(request.responseText);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -3369,7 +3369,7 @@ HttpProvider.prototype.sendAsync = function (payload, callback) {
|
|||
try {
|
||||
result = JSON.parse(result);
|
||||
} catch(e) {
|
||||
error = errors.InvalidResponse(result);
|
||||
error = errors.InvalidResponse(request.responseText);
|
||||
}
|
||||
|
||||
callback(error, result);
|
||||
|
@ -3583,7 +3583,7 @@ var IpcProvider = function (path, net) {
|
|||
clearTimeout(_this.lastChunkTimeout);
|
||||
_this.lastChunkTimeout = setTimeout(function(){
|
||||
_this.timeout();
|
||||
throw errors.InvalidResponse(result);
|
||||
throw errors.InvalidResponse(data);
|
||||
}, 1000 * 15);
|
||||
|
||||
return;
|
||||
|
@ -3666,12 +3666,12 @@ IpcProvider.prototype.send = function (payload) {
|
|||
if(!this.connection.writable)
|
||||
this.connection.connect({path: this.path});
|
||||
|
||||
var result = this.connection.writeSync(JSON.stringify(payload));
|
||||
var data = this.connection.writeSync(JSON.stringify(payload));
|
||||
|
||||
try {
|
||||
result = JSON.parse(result);
|
||||
result = JSON.parse(data);
|
||||
} catch(e) {
|
||||
throw errors.InvalidResponse(result);
|
||||
throw errors.InvalidResponse(data);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -31,7 +31,7 @@ module.exports = {
|
|||
return new Error('Providor not set or invalid');
|
||||
},
|
||||
InvalidResponse: function (result){
|
||||
var message = !!result && !!result.error && !!result.error.message ? result.error.message : 'Invalid JSON RPC response';
|
||||
var message = !!result && !!result.error && !!result.error.message ? result.error.message : 'Invalid JSON RPC response: '+ result;
|
||||
return new Error(message);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -74,7 +74,7 @@ HttpProvider.prototype.send = function (payload) {
|
|||
try {
|
||||
result = JSON.parse(result);
|
||||
} catch(e) {
|
||||
throw errors.InvalidResponse(result);
|
||||
throw errors.InvalidResponse(request.responseText);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -90,7 +90,7 @@ HttpProvider.prototype.sendAsync = function (payload, callback) {
|
|||
try {
|
||||
result = JSON.parse(result);
|
||||
} catch(e) {
|
||||
error = errors.InvalidResponse(result);
|
||||
error = errors.InvalidResponse(request.responseText);
|
||||
}
|
||||
|
||||
callback(error, result);
|
||||
|
|
|
@ -81,7 +81,7 @@ var IpcProvider = function (path, net) {
|
|||
clearTimeout(_this.lastChunkTimeout);
|
||||
_this.lastChunkTimeout = setTimeout(function(){
|
||||
_this.timeout();
|
||||
throw errors.InvalidResponse(result);
|
||||
throw errors.InvalidResponse(data);
|
||||
}, 1000 * 15);
|
||||
|
||||
return;
|
||||
|
@ -159,17 +159,18 @@ IpcProvider.prototype.isConnected = function() {
|
|||
IpcProvider.prototype.send = function (payload) {
|
||||
|
||||
if(this.connection.writeSync) {
|
||||
var result;
|
||||
|
||||
// try reconnect, when connection is gone
|
||||
if(!this.connection.writable)
|
||||
this.connection.connect({path: this.path});
|
||||
|
||||
var result = this.connection.writeSync(JSON.stringify(payload));
|
||||
var data = this.connection.writeSync(JSON.stringify(payload));
|
||||
|
||||
try {
|
||||
result = JSON.parse(result);
|
||||
result = JSON.parse(data);
|
||||
} catch(e) {
|
||||
throw errors.InvalidResponse(result);
|
||||
throw errors.InvalidResponse(data);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
Loading…
Reference in New Issue