pub struct PositionedParseError {
pub message: String,
pub range: TextPosition,
pub code: Option<String>,
pub kind: ParseErrorKind,
}Expand description
A positioned parse error containing location information.
Fields§
§message: StringThe error message
range: TextPositionThe text range where the error occurred
code: Option<String>Optional error code for categorization
kind: ParseErrorKindStructured error kind
Implementations§
Source§impl PositionedParseError
impl PositionedParseError
Sourcepub fn start_position(&self, source_text: &str) -> LineColumn
pub fn start_position(&self, source_text: &str) -> LineColumn
Get the line and column where this error starts (if source text is available).
§Arguments
source_text- The original YAML source text
§Returns
LineColumn with 1-indexed line and column numbers.
§Examples
use yaml_edit::{YamlFile, Parse};
use std::str::FromStr;
let text = "invalid:\n - [unclosed";
let parse = Parse::parse_yaml(text);
if let Some(err) = parse.positioned_errors().first() {
let pos = err.start_position(text);
assert_eq!(pos.line, 2);
}Sourcepub fn end_position(&self, source_text: &str) -> LineColumn
pub fn end_position(&self, source_text: &str) -> LineColumn
Trait Implementations§
Source§impl Clone for PositionedParseError
impl Clone for PositionedParseError
Source§fn clone(&self) -> PositionedParseError
fn clone(&self) -> PositionedParseError
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PositionedParseError
impl Debug for PositionedParseError
Source§impl Display for PositionedParseError
impl Display for PositionedParseError
Source§impl Error for PositionedParseError
impl Error for PositionedParseError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns 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()
Source§impl Hash for PositionedParseError
impl Hash for PositionedParseError
Source§impl PartialEq for PositionedParseError
impl PartialEq for PositionedParseError
impl Eq for PositionedParseError
impl StructuralPartialEq for PositionedParseError
Auto Trait Implementations§
impl Freeze for PositionedParseError
impl RefUnwindSafe for PositionedParseError
impl Send for PositionedParseError
impl Sync for PositionedParseError
impl Unpin for PositionedParseError
impl UnsafeUnpin for PositionedParseError
impl UnwindSafe for PositionedParseError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more