better error API handling
This commit is contained in:
parent
4e1562ce7a
commit
f619192708
@ -13,7 +13,7 @@ var mongoose = require('mongoose'),
|
|||||||
*/
|
*/
|
||||||
exports.block = function(req, res, next, hash) {
|
exports.block = function(req, res, next, hash) {
|
||||||
Block.fromHashWithInfo(hash, function(err, block) {
|
Block.fromHashWithInfo(hash, function(err, block) {
|
||||||
if (err || ! tx) return common.handleErrors(err, res, next);
|
if (err || ! block) return common.handleErrors(err, res, next);
|
||||||
|
|
||||||
req.block = block.info;
|
req.block = block.info;
|
||||||
return next();
|
return next();
|
||||||
|
|||||||
@ -92,7 +92,6 @@ BlockSchema.statics.fromHashWithInfo = function(hash, cb) {
|
|||||||
|
|
||||||
block.hash = hash;
|
block.hash = hash;
|
||||||
block.getInfo(function(err, blockInfo) {
|
block.getInfo(function(err, blockInfo) {
|
||||||
console.log('[Block.js.95:err:]',err); //TODO
|
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
if (!blockInfo) return cb();
|
if (!blockInfo) return cb();
|
||||||
|
|
||||||
|
|||||||
@ -8,8 +8,16 @@ angular.module('insight.address').controller('AddressController', ['$scope', '$r
|
|||||||
addrStr: $routeParams.addrStr
|
addrStr: $routeParams.addrStr
|
||||||
}, function(address) {
|
}, function(address) {
|
||||||
$scope.address = address;
|
$scope.address = address;
|
||||||
}, function() {
|
}, function(e) {
|
||||||
$rootScope.flashMessage = 'Address Not Found';
|
if (e.status === 400) {
|
||||||
|
$rootScope.flashMessage = 'Invalid Address: ' + $routeParams.addrStr;
|
||||||
|
}
|
||||||
|
else if (e.status === 503) {
|
||||||
|
$rootScope.flashMessage = 'Backend Error. ' + e.data;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$rootScope.flashMessage = 'Address Not Found';
|
||||||
|
}
|
||||||
$location.path('/');
|
$location.path('/');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -17,8 +17,16 @@ angular.module('insight.blocks').controller('BlocksController', ['$scope', '$roo
|
|||||||
blockHash: $routeParams.blockHash
|
blockHash: $routeParams.blockHash
|
||||||
}, function(block) {
|
}, function(block) {
|
||||||
$scope.block = block;
|
$scope.block = block;
|
||||||
}, function() {
|
}, function(e) {
|
||||||
$rootScope.flashMessage = 'Block Not Found';
|
if (e.status === 400) {
|
||||||
|
$rootScope.flashMessage = 'Invalid Transaction ID: ' + $routeParams.txId;
|
||||||
|
}
|
||||||
|
else if (e.status === 503) {
|
||||||
|
$rootScope.flashMessage = 'Backend Error. ' + e.data;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$rootScope.flashMessage = 'Block Not Found';
|
||||||
|
}
|
||||||
$location.path('/');
|
$location.path('/');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -8,8 +8,16 @@ angular.module('insight.transactions').controller('transactionsController', ['$s
|
|||||||
txId: $routeParams.txId
|
txId: $routeParams.txId
|
||||||
}, function(tx) {
|
}, function(tx) {
|
||||||
$scope.tx = tx;
|
$scope.tx = tx;
|
||||||
}, function() {
|
}, function(e) {
|
||||||
$rootScope.flashMessage = 'Transaction Not Found';
|
if (e.status === 400) {
|
||||||
|
$rootScope.flashMessage = 'Invalid Transaction ID: ' + $routeParams.txId;
|
||||||
|
}
|
||||||
|
else if (e.status === 503) {
|
||||||
|
$rootScope.flashMessage = 'Backend Error. ' + e.data;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$rootScope.flashMessage = 'Transaction Not Found';
|
||||||
|
}
|
||||||
$location.path('/');
|
$location.path('/');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user