Avoid raw Exception raises by moving confutils config load (#1461)

This commit is contained in:
Kim De Mey 2023-02-07 17:21:12 +01:00 committed by GitHub
parent c2fc46a99a
commit 77135e7001
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 18 deletions

View File

@ -65,7 +65,7 @@
import
std/[os, strutils, options],
web3/ethtypes,
chronicles, chronos,
chronicles, chronos, confutils,
eth/[keys, rlp], eth/[trie, trie/db],
# Need to rename this because of web3 ethtypes and ambigious indentifier mess
# for `BlockHeader`.
@ -155,13 +155,7 @@ proc asPortalBlockData*(
(hash, headerWithProof, body)
# TODO Find what can throw exception
proc run() {.raises: [Exception].} =
{.pop.}
var config = makeBannerAndConfig(
"Nimbus beacon chain bridge", BeaconBridgeConf)
{.push raises: [].}
proc run(config: BeaconBridgeConf) {.raises: [CatchableError].} =
# Required as both Eth2Node and LightClient requires correct config type
var lcConfig = config.asLightClientConf()
@ -388,4 +382,9 @@ proc run() {.raises: [Exception].} =
poll()
when isMainModule:
run()
{.pop.}
var config = makeBannerAndConfig(
"Nimbus beacon chain bridge", BeaconBridgeConf)
{.push raises: [].}
run(config)

View File

@ -9,7 +9,7 @@
import
std/[os, strutils],
chronicles, chronicles/chronos_tools, chronos,
chronicles, chronicles/chronos_tools, chronos, confutils,
eth/keys,
json_rpc/rpcproxy,
beacon_chain/eth1/eth1_monitor,
@ -40,13 +40,7 @@ func getConfiguredChainId(networkMetadata: Eth2NetworkMetadata): Quantity =
else:
return networkMetadata.cfg.DEPOSIT_CHAIN_ID.Quantity
# TODO Find what can throw exception
proc run() {.raises: [Exception].} =
{.pop.}
var config = makeBannerAndConfig(
"Nimbus verified proxy " & fullVersionStr, VerifiedProxyConf)
{.push raises: [].}
proc run(config: VerifiedProxyConf) {.raises: [CatchableError].} =
# Required as both Eth2Node and LightClient requires correct config type
var lcConfig = config.asLightClientConf()
@ -246,4 +240,9 @@ proc run() {.raises: [Exception].} =
poll()
when isMainModule:
run()
{.pop.}
var config = makeBannerAndConfig(
"Nimbus verified proxy " & fullVersionStr, VerifiedProxyConf)
{.push raises: [].}
run(config)