Handle this error properly. For instance, without this, if we cannot connect to the RPC client, JSON won't be able to parse the result (there is none), in which case would cause a RuntimeException.

This commit is contained in:
Tim Coulter 2015-04-30 13:52:41 -07:00
parent 798960743b
commit b064eaba20
7 changed files with 38 additions and 14 deletions

12
dist/web3-light.js vendored
View File

@ -2808,8 +2808,16 @@ HttpProvider.prototype.sendAsync = function (payload, callback) {
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
if (request.readyState === 4) {
// TODO: handle the error properly here!!!
callback(null, JSON.parse(request.responseText));
var result = request.responseText;
var error = null;
try {
result = JSON.parse(result);
} catch(e) {
error = errors.InvalidResponse(result);
}
callback(error, result);
}
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

12
dist/web3.js vendored
View File

@ -2808,8 +2808,16 @@ HttpProvider.prototype.sendAsync = function (payload, callback) {
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
if (request.readyState === 4) {
// TODO: handle the error properly here!!!
callback(null, JSON.parse(request.responseText));
var result = request.responseText;
var error = null;
try {
result = JSON.parse(result);
} catch(e) {
error = errors.InvalidResponse(result);
}
callback(error, result);
}
};

4
dist/web3.js.map vendored

File diff suppressed because one or more lines are too long

4
dist/web3.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -55,8 +55,16 @@ HttpProvider.prototype.sendAsync = function (payload, callback) {
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
if (request.readyState === 4) {
// TODO: handle the error properly here!!!
callback(null, JSON.parse(request.responseText));
var result = request.responseText;
var error = null;
try {
result = JSON.parse(result);
} catch(e) {
error = errors.InvalidResponse(result);
}
callback(error, result);
}
};