diff --git a/app/controllers/addresses.js b/app/controllers/addresses.js index f12087e9..30671ee1 100644 --- a/app/controllers/addresses.js +++ b/app/controllers/addresses.js @@ -19,10 +19,12 @@ exports.address = function(req, res, next, addr) { } a.update(function(err) { - if (err) return common.handleErrors(err, res, next); - - req.address = a; - return next(); + if (err) + return common.handleErrors(err, res); + else { + req.address = a; + return next(); + } }); }; diff --git a/app/controllers/blocks.js b/app/controllers/blocks.js index 316f17fa..37324a09 100644 --- a/app/controllers/blocks.js +++ b/app/controllers/blocks.js @@ -13,10 +13,12 @@ var mongoose = require('mongoose'), */ exports.block = function(req, res, next, hash) { Block.fromHashWithInfo(hash, function(err, block) { - if (err || ! block) return common.handleErrors(err, res, next); - - req.block = block.info; - return next(); + if (err || ! block) + return common.handleErrors(err, res, next); + else { + req.block = block.info; + return next(); + } }); }; diff --git a/app/controllers/common.js b/app/controllers/common.js index faae67cd..b44756bf 100644 --- a/app/controllers/common.js +++ b/app/controllers/common.js @@ -1,7 +1,7 @@ 'use strict'; -exports.handleErrors = function (err, res, next) { +exports.handleErrors = function (err, res) { if (err) { if (err.code) { res.status(400).send(err.message + '. Code:' + err.code); @@ -9,10 +9,8 @@ exports.handleErrors = function (err, res, next) { else { res.status(503).send(err.message); } - return next(); } else { res.status(404).send('Not found'); - return next(); } }; diff --git a/app/controllers/status.js b/app/controllers/status.js index 6652359e..1874605e 100644 --- a/app/controllers/status.js +++ b/app/controllers/status.js @@ -4,7 +4,8 @@ * Module dependencies. */ -var Status = require('../models/Status'); +var Status = require('../models/Status'), + common = require('./common'); /** * Status @@ -19,8 +20,11 @@ exports.show = function(req, res, next) { var statusObject = Status.new(); var returnJsonp = function (err) { - if(err) return next(err); - res.jsonp(statusObject); + if (err || ! statusObject) + return common.handleErrors(err, res); + else { + res.jsonp(statusObject); + } }; switch(option) { diff --git a/app/controllers/transactions.js b/app/controllers/transactions.js index c865f576..991dd217 100644 --- a/app/controllers/transactions.js +++ b/app/controllers/transactions.js @@ -15,12 +15,12 @@ var common = require('./common'); */ exports.transaction = function(req, res, next, txid) { Transaction.fromIdWithInfo(txid, function(err, tx) { - - if (err || ! tx) return common.handleErrors(err, res, next); - - - req.transaction = tx.info; - return next(); + if (err || ! tx) + return common.handleErrors(err, res); + else { + req.transaction = tx.info; + return next(); + } }); }; diff --git a/public/js/controllers/status.js b/public/js/controllers/status.js index dcfd52e5..8fa2f24b 100644 --- a/public/js/controllers/status.js +++ b/public/js/controllers/status.js @@ -7,15 +7,24 @@ angular.module('insight.status').controller('StatusController', ['$scope', '$rou Status.get({ q: 'get' + q }, function(d) { + $rootScope.infoError = null; angular.extend($scope, d); + }, function(e) { + if (e.status === 503) { + $rootScope.infoError = 'Backend Error. ' + e.data; + } + else { + $rootScope.infoError = 'Unknown error:' + e.data; + } }); }; $scope.getSync = function() { Sync.get({}, function(sync) { + $rootScope.syncError = null; $scope.sync = sync; - }, function() { - $rootScope.flashMessage = 'Could not get sync information'; + }, function(e) { + $rootScope.syncError = 'Could not get sync information' + e; }); }; }]); diff --git a/public/views/status.html b/public/views/status.html index ce4c8808..71951199 100644 --- a/public/views/status.html +++ b/public/views/status.html @@ -9,9 +9,10 @@

getInfo

- - - + + + @@ -65,8 +66,8 @@ - - + +
Loading...
Loading... +
{{infoError}}
Version {{info.version}}{{info.paytxfee}}
errors{{info.errors}}infoErrors{{info.infoErrors}}
@@ -75,8 +76,8 @@

sync status

- - + + @@ -125,9 +126,12 @@

getTxOutSetInfo

{{ syncError }}
{{ sync.err }}
- + + + + @@ -166,9 +170,13 @@

getDifficulty

Loading...
{{infoError}}
Height {{txoutsetinfo.height}}
- + + + + + @@ -180,10 +188,14 @@

getLastBlockHash

Loading...
{{infoError}}
Difficulty {{difficulty}}
- - + + + + + +
Loading...
Loading...
{{infoError}}
Last block hash {{lastblockhash}}