Add function to create Error from message String
This commit is contained in:
@@ -74,6 +74,12 @@ impl Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates a new basic `Error` at this location with the given message
|
||||||
|
#[track_caller]
|
||||||
|
pub fn message_here<S: Into<String>>(message: S) -> Self {
|
||||||
|
Error::new(ErrorType::Error(message.into()), ErrorLocation::here())
|
||||||
|
}
|
||||||
|
|
||||||
/// Adds a context message to the error
|
/// Adds a context message to the error
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn with_context(mut self, context: impl Into<String>) -> Self {
|
pub fn with_context(mut self, context: impl Into<String>) -> Self {
|
||||||
|
|||||||
Reference in New Issue
Block a user