Skip to content

Commit

Permalink
Allow Error::set_status to take TryInto<StatusCode>
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshuawuyts committed Sep 27, 2020
1 parent 7bf4ab6 commit c9d456e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,14 @@ impl Error {
}

/// Set the status code associated with this error.
pub fn set_status(&mut self, status: StatusCode) {
self.status = status;
pub fn set_status<S>(&mut self, status: S)
where
S: TryInto<StatusCode>,
S::Error: Debug,
{
self.status = status
.try_into()
.expect("Could not convert into a valid `StatusCode`");
}

/// Get the backtrace for this Error.
Expand Down

0 comments on commit c9d456e

Please sign in to comment.