File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -173,16 +173,24 @@ impl Error {
173
173
}
174
174
}
175
175
176
+ /// Create a new error object from static string.
177
+ pub fn from_str < M > ( kind : ErrorKind , msg : M , status : StatusCode ) -> Self
178
+ where
179
+ M : Display + Debug + Send + Sync + ' static ,
180
+ {
181
+ Self {
182
+ kind,
183
+ repr : Repr :: Custom ( anyhow:: format_err!( msg) ) ,
184
+ status,
185
+ }
186
+ }
187
+
176
188
/// Create a new error from a message.
177
189
pub ( crate ) fn new_adhoc < M > ( message : M ) -> Error
178
190
where
179
191
M : Display + Debug + Send + Sync + ' static ,
180
192
{
181
- Error {
182
- kind : ErrorKind :: Other ,
183
- repr : Repr :: Custom ( anyhow:: format_err!( message) ) ,
184
- status : StatusCode :: InternalServerError ,
185
- }
193
+ Self :: from_str ( ErrorKind :: Other , message, StatusCode :: InternalServerError )
186
194
}
187
195
188
196
/// Create a new error object from an I/O error.
You can’t perform that action at this time.
0 commit comments