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: not assigned yet
- status: not started
- start-date: 2026/07/15
- end-date: 2026/09/30
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