Struct git_config_value::Error
source · pub struct Error {
pub message: &'static str,
pub input: BString,
pub utf8_err: Option<Utf8Error>,
}
Expand description
The error returned when any config value couldn’t be instantiated due to malformed input.
Fields§
§message: &'static str
§input: BString
§utf8_err: Option<Utf8Error>
Implementations§
source§impl Error
impl Error
sourcepub fn new(message: &'static str, input: impl Into<BString>) -> Self
pub fn new(message: &'static str, input: impl Into<BString>) -> Self
Create a new value error from message
, with input
being what’s causing the error.
Examples found in repository?
src/boolean.rs (lines 8-11)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
fn bool_err(input: impl Into<BString>) -> Error {
Error::new(
"Booleans need to be 'no', 'off', 'false', '' or 'yes', 'on', 'true' or any number",
input,
)
}
impl TryFrom<OsString> for Boolean {
type Error = Error;
fn try_from(value: OsString) -> Result<Self, Self::Error> {
let value = git_path::os_str_into_bstr(&value)
.map_err(|_| Error::new("Illformed UTF-8", std::path::Path::new(&value).display().to_string()))?;
Self::try_from(value)
}
More examples
Trait Implementations§
source§impl Error for Error
impl Error for Error
source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()