Skip to content

refactor: migrate remaining throw statements to Result<T> in facade APIs #951

Description

@kcenon

What

45 throw std:: statements remain in 11 files across the network_system. The facade layer is the worst offender:

  • tcp_facade.cpp — 12 throws
  • quic_facade.cpp — 8 throws
  • udp_facade.cpp — 5 throws
  • websocket_facade.cpp — 3 throws
  • http_facade.cpp — 2 throws

The ecosystem convention is Result<T> (from common_system), and the core/internal layers already use it. This creates a mixed error-handling contract.

Why

Callers cannot use a uniform error-handling pattern. Functions that throw require try/catch while adjacent functions return Result<T>.

How

Technical Approach

  1. Change facade return types from raw shared_ptr to common::Result<shared_ptr<...>>
  2. Replace throw std::invalid_argument(...) with return Result::err(...)
  3. Update corresponding .h headers with new signatures
  4. Update test assertions

Acceptance Criteria

  • All 5 facade files return Result<T> instead of throwing
  • All 45 throw sites converted
  • Corresponding headers updated
  • Existing tests pass with Result-based assertions

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactoringCode refactoring and improvements

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions