[−][src]Struct lenient_semver::Error
Possible errors that happen during parsing and the location of the token where the error occurred.
Example
use semver::Version; let error = lenient_semver::parse("1+").unwrap_err(); assert_eq!(error.to_string(), "Could not parse the build identifier: No input"); let error = lenient_semver::parse("1!").unwrap_err(); assert_eq!(error.to_string(), "Unexpected `!`");
Implementations
impl<'input> Error<'input>[src]
pub fn owned(&self) -> OwnedError[src]
Creates a new OwnedError out of this Error.
This is specialized version of Clone which returns a different type.
pub fn input(&self) -> &'input str[src]
Returns the original input line.
Examples
let error = lenient_semver::parse("1+").unwrap_err(); assert_eq!(error.input(), "1+");
pub fn error_span(&self) -> Range<usize>[src]
Returns range into the input string that points to the erroneous input.
Examples
let error = lenient_semver::parse("1+").unwrap_err(); assert_eq!(error.error_span(), 1..2);
pub fn error_kind(&self) -> ErrorKind[src]
Returns the kind of error.
Examples
assert_eq!( lenient_semver::parse("").unwrap_err().error_kind(), lenient_semver::ErrorKind::MissingMajorNumber ); assert_eq!( lenient_semver::parse("1.").unwrap_err().error_kind(), lenient_semver::ErrorKind::MissingMinorNumber ); assert_eq!( lenient_semver::parse("1.2.").unwrap_err().error_kind(), lenient_semver::ErrorKind::MissingPatchNumber ); assert_eq!( lenient_semver::parse("1-").unwrap_err().error_kind(), lenient_semver::ErrorKind::MissingPreRelease ); assert_eq!( lenient_semver::parse("1+").unwrap_err().error_kind(), lenient_semver::ErrorKind::MissingBuild ); assert_eq!( lenient_semver::parse("1!").unwrap_err().error_kind(), lenient_semver::ErrorKind::UnexpectedInput );
pub fn erroneous_input(&self) -> &'input str[src]
Returns a slice from the original input line that triggered the error.
Examples
let error = lenient_semver::parse("1+").unwrap_err(); assert_eq!(error.erroneous_input(), "+");
pub fn error_line(&self) -> String[src]
Returns a text representation of the error.
Examples
let error = lenient_semver::parse("1.").unwrap_err(); assert_eq!(error.error_line(), String::from("Could not parse the minor identifier: No input"));
This is equivalent to the Display implementation, which can be further customized with format specifiers.
let error = lenient_semver::parse("1?").unwrap_err(); assert_eq!(format!("{:!^42}", error), String::from("!!!!!!!!!!!!!!Unexpected `?`!!!!!!!!!!!!!!"));
pub fn indicate_erroneous_input(&self) -> String[src]
Returns a caret line indication the erroneous input if it was written under the original input line.
Examples
let error = lenient_semver::parse("foo").unwrap_err(); assert_eq!(error.indicate_erroneous_input(), "^^^"); let error = lenient_semver::parse("1.2.3 bar").unwrap_err(); assert_eq!(error.indicate_erroneous_input(), "~~~~~~^^^");
Trait Implementations
impl<'input> Debug for Error<'input>[src]
impl<'_> Display for Error<'_>[src]
impl<'input> Eq for Error<'input>[src]
impl<'_> Error for Error<'_>[src]
fn source(&self) -> Option<&(dyn Error + 'static)>1.30.0[src]
fn backtrace(&self) -> Option<&Backtrace>[src]
fn description(&self) -> &str1.0.0[src]
fn cause(&self) -> Option<&dyn Error>1.0.0[src]
impl<'input> PartialEq<Error<'input>> for Error<'input>[src]
impl<'input> StructuralEq for Error<'input>[src]
impl<'input> StructuralPartialEq for Error<'input>[src]
Auto Trait Implementations
impl<'input> RefUnwindSafe for Error<'input>
impl<'input> Send for Error<'input>
impl<'input> Sync for Error<'input>
impl<'input> Unpin for Error<'input>
impl<'input> UnwindSafe for Error<'input>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,