Skip to content

Use error enums instead of Anyhow #106

Closed
@algesten

Description

@algesten

Original discussion on discord, and further issue raised here: webrtc-rs/rtp#14

Anyhow is great, but maybe not a good fit for webrtc.rs. To summarize:

  • Anyhow is mostly meant for applications, not libraries.
  • Anyhow doesn't implement std::error::Error (it can't), which makes it hard to interoperate in apps that rely on that.
  • Not having explicit enumerations of possible errors means the webrtc.rs API effectively have "hidden" code paths. It's not possible for a user to know which errors could potentially be thrown from an API call returning anyhow::Result<X>

Way forward

  • Replace anyhow with idiomatic Rust error enums.
  • Keep thiserror to help implement said enums.
  • Maintain ergonomics for ? use internally in webrtc.rs (work with From traits and rewrap errors).
  • Bring out possible errors in API calls. Either via types or documentation.

This issue will be used to coordinate the effort which will span all the sub-crates.

  • sdp
  • util (done, but deliberately marked as draft)
  • mdns
  • stun
  • turn
  • ice
  • dtls
  • rtp
  • rtcp
  • srtp
  • sctp
  • media
  • interceptor
  • data
  • webrtc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions