diff options
author | Alex Browne <stephenalexbrowne@gmail.com> | 2018-11-09 03:38:37 +0800 |
---|---|---|
committer | Alex Browne <stephenalexbrowne@gmail.com> | 2018-12-05 06:24:48 +0800 |
commit | 410a9244952b663fa8e56cc778b712ae228bbd82 (patch) | |
tree | ef9951abc2c867596c23bce159aca6f3536efe65 /packages/pipeline/src/scripts/pull_missing_events.ts | |
parent | 53cc9e9bedc6adf2247a190dbb758c9411033cab (diff) | |
download | dexon-0x-contracts-410a9244952b663fa8e56cc778b712ae228bbd82.tar dexon-0x-contracts-410a9244952b663fa8e56cc778b712ae228bbd82.tar.gz dexon-0x-contracts-410a9244952b663fa8e56cc778b712ae228bbd82.tar.bz2 dexon-0x-contracts-410a9244952b663fa8e56cc778b712ae228bbd82.tar.lz dexon-0x-contracts-410a9244952b663fa8e56cc778b712ae228bbd82.tar.xz dexon-0x-contracts-410a9244952b663fa8e56cc778b712ae228bbd82.tar.zst dexon-0x-contracts-410a9244952b663fa8e56cc778b712ae228bbd82.zip |
Add better error handling for immediately invoked async functions
Diffstat (limited to 'packages/pipeline/src/scripts/pull_missing_events.ts')
-rw-r--r-- | packages/pipeline/src/scripts/pull_missing_events.ts | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/packages/pipeline/src/scripts/pull_missing_events.ts b/packages/pipeline/src/scripts/pull_missing_events.ts index a108f012f..cca0d9cfe 100644 --- a/packages/pipeline/src/scripts/pull_missing_events.ts +++ b/packages/pipeline/src/scripts/pull_missing_events.ts @@ -8,6 +8,7 @@ import { ExchangeEventsSource } from '../data_sources/contract-wrappers/exchange import { ExchangeFillEvent } from '../entities'; import { deployConfig } from '../ormconfig'; import { parseExchangeEvents } from '../parsers/events'; +import { handleError } from '../utils'; const EXCHANGE_START_BLOCK = 6271590; // Block number when the Exchange contract was deployed to mainnet. const START_BLOCK_OFFSET = 1000; // Number of blocks before the last known block to consider when updating fill events. @@ -22,7 +23,7 @@ let connection: Connection; }); await getExchangeEventsAsync(provider); process.exit(0); -})(); +})().catch(handleError); async function getExchangeEventsAsync(provider: Web3ProviderEngine): Promise<void> { console.log('Checking existing event logs...'); @@ -53,8 +54,8 @@ async function getStartBlockAsync(eventsRepository: Repository<ExchangeFillEvent return EXCHANGE_START_BLOCK; } const queryResult = await connection.query( - 'SELECT "blockNumber" FROM exchange_fill_event ORDER BY "blockNumber" DESC LIMIT 1', + 'SELECT block_number FROM exchange_fill_events ORDER BY block_number DESC LIMIT 1', ); - const lastKnownBlock = queryResult[0].blockNumber; + const lastKnownBlock = queryResult[0].block_number; return lastKnownBlock - START_BLOCK_OFFSET; } |