avoid pointless exception raising in dcutr/server (#1063)

This commit is contained in:
Etan Kissling 2024-03-12 18:29:01 +01:00 committed by GitHub
parent 08a48faf41
commit 49a92e5641
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -19,7 +19,6 @@ import ../../protocol,
../../../switch, ../../../switch,
../../../utils/future ../../../utils/future
export DcutrError
export chronicles export chronicles
type Dcutr* = ref object of LPProtocol type Dcutr* = ref object of LPProtocol
@ -65,14 +64,14 @@ proc new*(T: typedesc[Dcutr], switch: Switch, connectTimeout = 15.seconds, maxDi
except CancelledError as err: except CancelledError as err:
raise err raise err
except AllFuturesFailedError as err: except AllFuturesFailedError as err:
debug "Dcutr receiver could not connect to the remote peer, all connect attempts failed", peerDialableAddrs, msg = err.msg debug "Dcutr receiver could not connect to the remote peer, " &
raise newException(DcutrError, "Dcutr receiver could not connect to the remote peer, all connect attempts failed", err) "all connect attempts failed", peerDialableAddrs, msg = err.msg
except AsyncTimeoutError as err: except AsyncTimeoutError as err:
debug "Dcutr receiver could not connect to the remote peer, all connect attempts timed out", peerDialableAddrs, msg = err.msg debug "Dcutr receiver could not connect to the remote peer, " &
raise newException(DcutrError, "Dcutr receiver could not connect to the remote peer, all connect attempts timed out", err) "all connect attempts timed out", peerDialableAddrs, msg = err.msg
except CatchableError as err: except CatchableError as err:
warn "Unexpected error when Dcutr receiver tried to connect to the remote peer", msg = err.msg warn "Unexpected error when Dcutr receiver tried to connect " &
raise newException(DcutrError, "Unexpected error when Dcutr receiver tried to connect to the remote peer", err) "to the remote peer", msg = err.msg
let self = T() let self = T()
self.handler = handleStream self.handler = handleStream