pub struct ValueError { /* private fields */ }Expand description
The reason why the raw text of a value does not parse.
The config code of this crate maps the reason with the group and the key
of the value, and gives a ConfigError. The ostrya crate converts
each variant to the variant of ostrya::Error with the same name, with
the same text.
- A text that is not a boolean gives
ConfigError::Corewith the textvalue 'VALUE' for GROUP.KEY is not a boolean, asKeyFile::get_boolgives it. An integer givesis not an integerin the same form. - A malformed escape sequence gives
ConfigError::Corewith the text ofKeyFile::get_string. - An error of
malformed_itemormalformed_valuegivesConfigError::InvalidFormatwith the textmalformed [GROUP] KEY item 'TEXT': WHYormalformed [GROUP] KEY value 'TEXT': WHY. - Each other reason gives
ConfigError::InvalidFormatwith the text[GROUP] KEY REASON.GROUPis the group header, for examplecoreorremote "origin".
Implementations§
Source§impl ValueError
impl ValueError
Sourcepub fn new(reason: impl Into<String>) -> ValueError
pub fn new(reason: impl Into<String>) -> ValueError
Returns an error with the reason reason.
The reason is a predicate on the value, for example is empty, or
value 'x' is not a host name. A typed read writes it after the group
and the key: [GROUP] KEY REASON.
Sourcepub fn malformed_item(
text: impl Into<String>,
why: impl Into<String>,
) -> ValueError
pub fn malformed_item( text: impl Into<String>, why: impl Into<String>, ) -> ValueError
Returns the error of the malformed item text of a list value, with
the reason why.
A typed read gives the text malformed [GROUP] KEY item 'TEXT': WHY.
The Display form of the error alone is
malformed item 'TEXT': WHY.
§Examples
use ostrya_core::config::ValueError;
let err = ValueError::malformed_item("x", "the item is a number");
assert_eq!(err.to_string(), "malformed item 'x': the item is a number");Sourcepub fn malformed_value(
text: impl Into<String>,
why: impl Into<String>,
) -> ValueError
pub fn malformed_value( text: impl Into<String>, why: impl Into<String>, ) -> ValueError
Returns the error of the malformed value text, with the reason
why.
A typed read gives the text malformed [GROUP] KEY value 'TEXT': WHY. The Display form of the error alone is
malformed value 'TEXT': WHY.
§Examples
use ostrya_core::config::ValueError;
let err = ValueError::malformed_value("x", "the value is a number");
assert_eq!(err.to_string(), "malformed value 'x': the value is a number");Trait Implementations§
Source§impl Clone for ValueError
impl Clone for ValueError
Source§impl Debug for ValueError
impl Debug for ValueError
Source§impl Display for ValueError
impl Display for ValueError
impl Eq for ValueError
Source§impl Error for ValueError
impl Error for ValueError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()