Skip to content

Commit fe70de4

Browse files
committed
improve error msg around errors
1 parent 7c521d9 commit fe70de4

1 file changed

Lines changed: 28 additions & 12 deletions

File tree

src/templates/pools/pools.ts

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -554,12 +554,20 @@ export const createAeroProcessor = () => {
554554
const data = aerodromePoolFactoryAbi.events.PoolCreated.decode(log)
555555
const token0Contract = new erc20Abi.Contract(ctx, block.header, data.token0)
556556
const token1Contract = new erc20Abi.Contract(ctx, block.header, data.token1)
557-
const [symbol0, symbol1, decimals0, decimals1] = await Promise.all([
558-
token0Contract.symbol(),
559-
token1Contract.symbol(),
560-
token0Contract.decimals(),
561-
token1Contract.decimals(),
562-
])
557+
let symbol0: string, symbol1: string, decimals0: number, decimals1: number
558+
try {
559+
;[symbol0, symbol1, decimals0, decimals1] = await Promise.all([
560+
token0Contract.symbol(),
561+
token1Contract.symbol(),
562+
token0Contract.decimals(),
563+
token1Contract.decimals(),
564+
])
565+
} catch (err) {
566+
throw new Error(
567+
`Failed to fetch ERC20 metadata for Aerodrome pool ${data.pool} at block ${block.header.height}. ` +
568+
`token0=${data.token0}, token1=${data.token1}. Original error: ${err}`,
569+
)
570+
}
563571
const type = data.stable ? 'sAMM' : 'vAMM'
564572
const pool = new Pool({
565573
id: `${ctx.chain.id}:${data.pool}`,
@@ -580,12 +588,20 @@ export const createAeroProcessor = () => {
580588
const data = aerodromeCLPoolFactoryAbi.events.PoolCreated.decode(log)
581589
const token0Contract = new erc20Abi.Contract(ctx, block.header, data.token0)
582590
const token1Contract = new erc20Abi.Contract(ctx, block.header, data.token1)
583-
const [symbol0, symbol1, decimals0, decimals1] = await Promise.all([
584-
token0Contract.symbol(),
585-
token1Contract.symbol(),
586-
token0Contract.decimals(),
587-
token1Contract.decimals(),
588-
])
591+
let symbol0: string, symbol1: string, decimals0: number, decimals1: number
592+
try {
593+
;[symbol0, symbol1, decimals0, decimals1] = await Promise.all([
594+
token0Contract.symbol(),
595+
token1Contract.symbol(),
596+
token0Contract.decimals(),
597+
token1Contract.decimals(),
598+
])
599+
} catch (err) {
600+
throw new Error(
601+
`Failed to fetch ERC20 metadata for Aerodrome CL pool ${data.pool} at block ${block.header.height}. ` +
602+
`token0=${data.token0}, token1=${data.token1}. Original error: ${err}`,
603+
)
604+
}
589605
const type = `CL${data.tickSpacing}`
590606
const pool = new Pool({
591607
id: `${ctx.chain.id}:${data.pool}`,

0 commit comments

Comments
 (0)