ift-ts:p2p:ift:2026q3-nimlibp2p-result-error-handling
Audit code paths that use exceptions for expected failures and replace them
with explicit Result[T, error] handling where practical.
Description
Exceptions should remain available for cancellation and genuinely exceptional
conditions, but expected runtime failures are easier to reason about when they
are returned explicitly. This commitment moves selected nim-libp2p paths toward
Result[T, error] while preserving compatibility and avoiding broad churn.
Task List
Result Conversion
- fully qualified name:
ift-ts:p2p:ift:2026q3-nimlibp2p-result-error-handling:result-conversion - owner: Gabe
- status: done
- start-date: 2026/07/15
- end-date: 2026/09/29
Description
Convert to Result[T, error] wherever exceptions are used for expected failures, prioritizing
transport setup, address parsing, peer info parsing, protocol negotiation, Kademlia, discovery,
and builder configuration. Keep CancelledError and other cancellation semantics intact.
Prefer to keep the public API unchanged if possible.
Deliverables
- Selected APIs return explicit result values for expected failures
- Error types preserve useful context and messages
- Existing callers updated to handle result values
- Tests cover success and expected failure paths
- Migration notes for changed APIs
- vacp2p/nim-libp2p#3144 chore(result): connectivity clients
- vacp2p/nim-libp2p#3142 chore(result): wstransport
- vacp2p/nim-libp2p#3136 chore(result): upgrade managers and dialer return Result
- vacp2p/nim-libp2p#3143 chore(result): quic transport
- vacp2p/nim-libp2p#3137 chore(result): tcp and tor transports return Result internally
- vacp2p/nim-libp2p#3123 chore(result): multistream negotiation and PeerInfo.init return Result
- iftech/nim-libp2p#3160 chore(result): PeerIDAuth client
- iftech/nim-libp2p#3179 chore(result): add LPResult alias for core and transports
- iftech/nim-libp2p#3177 chore(result): NATService, switch mount and builders
- iftech/nim-libp2p#3176 chore(result): dialer connect path and ConnManager store return Result
- iftech/nim-libp2p#3163 chore(result): AutoTLS ACME API
- iftech/nim-libp2p#3162 chore(result): AutoTLS service, JWS and utils
- iftech/nim-libp2p#3159 chore(result): rendezvous
- logos-messaging/nim-ffi#204 test(ci): run the example programs and check their results
- iftech/nim-libp2p#3157 chore(result): relay client and transport
- iftech/nim-libp2p#3187 chore(result): add LPResultError type
- iftech/nim-libp2p#3188 chore(result): use LPResult alias in protocols