mirror of https://github.com/status-im/web3.js.git
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:
parent
798960743b
commit
b064eaba20
|
@ -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
|
@ -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
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue