response.balances = balances
for (const [address, data] of Object.entries(body.balances) as [string, unknown][]) {
if (Account.isValid(address)) {
- balances[address] = account_balance(data)
+ try {
+ balances[address] = account_balance(data)
+ } catch (err: any) {
+ const errors = response.errors ?? Object.create(null)
+ response.errors = errors
+ errors[address] = err?.message ?? 'Invalid account balance'
+ }
}
}
}
response.frontiers = frontiers
for (const [address, frontier] of Object.entries(body.frontiers) as [string, unknown][]) {
if (Account.isValid(address) && hex.is(frontier, 64)) {
- frontiers[address] = frontier
+ try {
+ frontiers[address] = frontier
+ } catch (err: any) {
+ const errors = response.errors ?? Object.create(null)
+ response.errors = errors
+ errors[address] = err?.message ?? 'Invalid account balance'
+ }
}
}
}
response.blocks = blocks
for (const [hash, data] of Object.entries(body.blocks) as [string, unknown][]) {
if (hex.is(hash, 64)) {
- blocks[hash] = block_info(data)
+ try {
+ blocks[hash] = block_info(data)
+ } catch (err: any) {
+ const errors = response.errors ?? Object.create(null)
+ response.errors = errors
+ errors[hash] = err?.message ?? 'Invalid block'
+ }
}
}
}