Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions iroh/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,21 @@ pub enum AcceptError {

impl AcceptError {
/// Creates a new user error from an arbitrary error type.
// TODO(Frando): Rename to `from_std`
#[track_caller]
pub fn from_err<T: std::error::Error + Send + Sync + 'static>(value: T) -> Self {
e!(AcceptError::User {
source: AnyError::from_std(value)
})
}

/// Creates a new user error from an arbitrary boxed error.
#[track_caller]
pub fn from_boxed(value: Box<dyn std::error::Error + Send + Sync>) -> Self {
e!(AcceptError::User {
source: AnyError::from_std_box(value)
})
}
}

impl From<std::io::Error> for AcceptError {
Expand Down
Loading