mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-24 03:58:13 +00:00
added better error reporting for missing receipts
This commit is contained in:
parent
228fa2b1fe
commit
ba43098215
@ -169,7 +169,7 @@ Method.prototype._confirmTransaction = function (defer, result, payload, extraFo
|
||||
payload.params[0].data &&
|
||||
payload.params[0].from &&
|
||||
!payload.params[0].to,
|
||||
receiptError = new Error('Failed to check for transaction receipt.');
|
||||
receiptError = 'Failed to check for transaction receipt:';
|
||||
|
||||
|
||||
// fire "receipt" and confirmation events and resolve after
|
||||
@ -178,10 +178,10 @@ Method.prototype._confirmTransaction = function (defer, result, payload, extraFo
|
||||
|
||||
method.eth.getTransactionReceipt(result)
|
||||
// catch error from requesting receipt
|
||||
.catch(function () {
|
||||
.catch(function (err) {
|
||||
sub.unsubscribe();
|
||||
promiseResolved = true;
|
||||
utils._fireError(receiptError, defer.eventEmitter, defer.reject);
|
||||
utils._fireError({message: receiptError, data: err}, defer.eventEmitter, defer.reject);
|
||||
})
|
||||
// if CONFIRMATION listener exists check for confirmations, by setting canUnsubscribe = false
|
||||
.then(function(receipt) {
|
||||
@ -254,7 +254,7 @@ Method.prototype._confirmTransaction = function (defer, result, payload, extraFo
|
||||
|
||||
return receipt;
|
||||
})
|
||||
// CHECK for normal tx check for receipt only
|
||||
// CHECK for normal tx check for receipt only
|
||||
.then(function(receipt) {
|
||||
|
||||
if (!isContractDeployment && !promiseResolved) {
|
||||
@ -294,7 +294,7 @@ Method.prototype._confirmTransaction = function (defer, result, payload, extraFo
|
||||
} else {
|
||||
sub.unsubscribe();
|
||||
promiseResolved = true;
|
||||
utils._fireError(receiptError, defer.eventEmitter, defer.reject);
|
||||
utils._fireError({message: receiptError, data: err}, defer.eventEmitter, defer.reject);
|
||||
}
|
||||
});
|
||||
};
|
||||
@ -343,10 +343,7 @@ Method.prototype.buildCall = function() {
|
||||
|
||||
defer.eventEmitter.emit('transactionHash', result);
|
||||
|
||||
|
||||
method._confirmTransaction(defer, result, payload, extraFromatters);
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -34,13 +34,27 @@ var keccak256 = require("js-sha3").keccak_256; // jshint ignore:line
|
||||
* Fires an error in an event emitter and callback and returns the eventemitter
|
||||
*
|
||||
* @method _fireError
|
||||
* @param {Object} error
|
||||
* @param {Object} error a string, a error, or an object with {message, data}
|
||||
* @param {Object} emitter
|
||||
* @param {Function} reject
|
||||
* @param {Function} callback
|
||||
* @return {Object} the emitter
|
||||
*/
|
||||
var _fireError = function (error, emitter, reject, callback) {
|
||||
/*jshint maxcomplexity: 10 */
|
||||
|
||||
// add data if given
|
||||
if(_.isObject(error) && !(error instanceof Error) && error.data) {
|
||||
if(_.isObject(error.data) || _.isArray(error.data)) {
|
||||
error.data = JSON.stringify(error.data, null, 2);
|
||||
}
|
||||
|
||||
error = error.message +"\n"+ error.data;
|
||||
}
|
||||
|
||||
if(_.isString(error)) {
|
||||
error = new Error(error);
|
||||
}
|
||||
|
||||
if (_.isFunction(callback)) {
|
||||
callback(error);
|
||||
|
Loading…
x
Reference in New Issue
Block a user