Handle errors gracefully.
This commit is contained in:
parent
0d67bc36ee
commit
f3c8e2134b
@ -6,13 +6,15 @@ import { DB } from '../../database';
|
|||||||
import logger from '../../logger';
|
import logger from '../../logger';
|
||||||
|
|
||||||
class ElementsParser {
|
class ElementsParser {
|
||||||
isRunning = false;
|
private isRunning = false;
|
||||||
|
|
||||||
constructor() { }
|
constructor() { }
|
||||||
|
|
||||||
public async $parse() {
|
public async $parse() {
|
||||||
if (this.isRunning) {
|
if (this.isRunning) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
this.isRunning = true;
|
this.isRunning = true;
|
||||||
const result = await bitcoinClient.getChainTips();
|
const result = await bitcoinClient.getChainTips();
|
||||||
const tip = result[0].height;
|
const tip = result[0].height;
|
||||||
@ -24,6 +26,10 @@ class ElementsParser {
|
|||||||
await this.$saveLatestBlockToDatabase(block.height, block.time, block.hash);
|
await this.$saveLatestBlockToDatabase(block.height, block.time, block.hash);
|
||||||
}
|
}
|
||||||
this.isRunning = false;
|
this.isRunning = false;
|
||||||
|
} catch (e) {
|
||||||
|
this.isRunning = false;
|
||||||
|
throw new Error(e instanceof Error ? e.message : 'Error');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async $getPegDataByMonth(): Promise<any> {
|
public async $getPegDataByMonth(): Promise<any> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user