Skip to content

Commit 280cfc6

Browse files
authored
feat: add AcceptError::from_boxed (#3620)
## Description This allows to do `AcceptError::from_boxed(anyhow_err.into_boxed_dyn_error())` ## Breaking Changes <!-- Optional, if there are any breaking changes document them, including how to migrate older code. --> ## Notes & open questions <!-- Any notes, remarks or open questions you have to make about the PR. --> ## Change checklist <!-- Remove any that are not relevant. --> - [ ] Self-review. - [ ] Documentation updates following the [style guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text), if relevant. - [ ] Tests if relevant. - [ ] All breaking changes documented. - [ ] List all breaking changes in the above "Breaking Changes" section. - [ ] Open an issue or PR on any number0 repos that are affected by this breaking change. Give guidance on how the updates should be handled or do the actual updates themselves. The major ones are: - [ ] [`quic-rpc`](https://github.com/n0-computer/quic-rpc) - [ ] [`iroh-gossip`](https://github.com/n0-computer/iroh-gossip) - [ ] [`iroh-blobs`](https://github.com/n0-computer/iroh-blobs) - [ ] [`dumbpipe`](https://github.com/n0-computer/dumbpipe) - [ ] [`sendme`](https://github.com/n0-computer/sendme)
1 parent b7e5bb0 commit 280cfc6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

iroh/src/protocol.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,21 @@ pub enum AcceptError {
123123

124124
impl AcceptError {
125125
/// Creates a new user error from an arbitrary error type.
126+
// TODO(Frando): Rename to `from_std`
126127
#[track_caller]
127128
pub fn from_err<T: std::error::Error + Send + Sync + 'static>(value: T) -> Self {
128129
e!(AcceptError::User {
129130
source: AnyError::from_std(value)
130131
})
131132
}
133+
134+
/// Creates a new user error from an arbitrary boxed error.
135+
#[track_caller]
136+
pub fn from_boxed(value: Box<dyn std::error::Error + Send + Sync>) -> Self {
137+
e!(AcceptError::User {
138+
source: AnyError::from_std_box(value)
139+
})
140+
}
132141
}
133142

134143
impl From<std::io::Error> for AcceptError {

0 commit comments

Comments
 (0)