display un parseable string, on Invlaid JSON RPC response error

This commit is contained in:
Fabian Vogelsteller 2015-07-09 17:35:29 +02:00
parent ccc4331d98
commit 7be511e51f
7 changed files with 27 additions and 26 deletions

14
dist/web3-light.js vendored
View File

@ -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

14
dist/web3.js vendored
View File

@ -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;

6
dist/web3.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -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);
}
};

View File

@ -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);

View File

@ -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;