Skip to content

Commit c8d4b9d

Browse files
committed
Allow Error::set_status to take TryInto<StatusCode>
1 parent e708c7d commit c8d4b9d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/error.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,14 @@ impl Error {
6969
}
7070

7171
/// Set the status code associated with this error.
72-
pub fn set_status(&mut self, status: StatusCode) {
73-
self.status = status;
72+
pub fn set_status<S>(&mut self, status: S)
73+
where
74+
S: TryInto<StatusCode>,
75+
S::Error: Debug,
76+
{
77+
self.status = status
78+
.try_into()
79+
.expect("Could not convert into a valid `StatusCode`");
7480
}
7581

7682
/// Get the backtrace for this Error.

0 commit comments

Comments
 (0)