Skip to content

Commit 2a037e0

Browse files
committed
improve error handling
1 parent 24c4794 commit 2a037e0

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

import/hbase/history.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ var HistoricalImport = function () {
140140

141141
} else if (resp) {
142142
self.importer.backFill(resp.startIndex, resp.stopIndex, function(err) {
143-
console.log(err);
144143
if (err) {
145144
if (cb) cb(err);
146145
}

import/postgres/history.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ var HistoricalImport = function () {
7575
if (err) {
7676
log.error('failed to get latest validated ledger');
7777
callback('failed to get latest validated ledger');
78-
return;
78+
process.exit(1);
7979
}
8080

8181
var index = parseInt(ledger.ledger_index, 10) - 1;
@@ -128,7 +128,13 @@ var HistoricalImport = function () {
128128
resp.stopIndex = GENESIS_LEDGER;
129129
}
130130

131-
self.importer.backFill(resp.stopIndex, resp.startIndex);
131+
self.importer.backFill(resp.stopIndex, resp.startIndex, function(err) {
132+
if (err) {
133+
log.error(err);
134+
process.exit(1);
135+
}
136+
});
137+
132138
self.count = 0;
133139
self.total = resp.startIndex - resp.stopIndex + 1;
134140
self.section = resp;

lib/ripple-importer.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,17 @@ var Importer = function (options) {
124124
*/
125125
function getLedger(index, count) {
126126
if (!count) count = 0;
127-
127+
var max = 5;
128128
setTimeout(function() {
129129
self.getLedger({index:index || 'validated'}, function (err, ledger) {
130130
if (ledger) handleLedger(ledger);
131131
else {
132132
log.error(err);
133-
if (count++<30) {
133+
if (count ++< max) {
134134
log.error('backfiller failed to get ledger, retrying: ' + count);
135135
getLedger(index, count);
136136
} else {
137-
log.error('backfiller failed to get ledger, stopping after 30 attempts');
137+
log.error('backfiller failed to get ledger, stopping after ' + max + ' attempts');
138138
if (typeof callback === 'function') {
139139
callback('import failure');
140140
}
@@ -427,8 +427,7 @@ var Importer = function (options) {
427427
}
428428

429429
if (!valid) {
430-
log.error('unable to validate ledger:', resp.ledger.ledger_index);
431-
retry(Number(resp.ledger.ledger_index), attempts, callback);
430+
callback('unable to validate ledger: ' + resp.ledger.ledger_index);
432431
return;
433432
}
434433

0 commit comments

Comments
 (0)