pub enum HkError {
Io(Error),
Parse {
line: u32,
column: usize,
message: String,
},
TypeMismatch {
expected: String,
found: String,
},
MissingField(String),
InvalidReference(String),
CyclicReference(String),
KeyConflict(String),
}Expand description
Custom error type for parsing .hk files.
Variants§
Io(Error)
Parse
TypeMismatch
MissingField(String)
InvalidReference(String)
CyclicReference(String)
KeyConflict(String)
Implementations§
Source§impl HkError
impl HkError
Sourcepub fn render(&self, source: &str) -> String
pub fn render(&self, source: &str) -> String
Renders the error as a multi-line, rustc-style string: a boxed
snippet of the surrounding source (when available) with a ^
caret under the exact column, plus a short “hint” for common
mistakes. Returned as a String (rather than printed directly)
so callers can log it, show it in a UI, write it to a file, or
just print it — pretty_print below is a thin convenience
wrapper around this that prints to stderr, kept for backwards
compatibility with existing callers.
Sourcepub fn pretty_print(&self, source: &str)
pub fn pretty_print(&self, source: &str)
Prints render(source) to stderr. Kept for backwards compatibility
with existing callers (e.g. hpm’s own CLI) that expect this method
to exist and print for them.
Trait Implementations§
Source§impl Error for HkError
impl Error for HkError
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()
Auto Trait Implementations§
impl !RefUnwindSafe for HkError
impl !UnwindSafe for HkError
impl Freeze for HkError
impl Send for HkError
impl Sync for HkError
impl Unpin for HkError
impl UnsafeUnpin for HkError
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