pub struct FileError {
pub path: PathBuf,
pub line: Option<u32>,
pub column: Option<u32>,
pub message: String,
pub error_code: Option<String>,
}Expand description
Error for a specific file with location context.
Tracks file path and optional line/column information for errors that occur during file processing (parsing, analysis, etc.).
§Example
use debtmap::effects::validation::FileError;
use std::path::PathBuf;
let error = FileError::new(
PathBuf::from("src/main.rs"),
"unexpected token 'foo'"
).at_location(42, 15);
assert_eq!(error.path, PathBuf::from("src/main.rs"));
assert_eq!(error.line, Some(42));
assert_eq!(error.column, Some(15));Fields§
§path: PathBufPath to the file where the error occurred.
line: Option<u32>Line number where the error occurred (1-indexed).
column: Option<u32>Column number where the error occurred (1-indexed).
message: StringHuman-readable error message.
error_code: Option<String>Optional error code for programmatic handling.
Implementations§
Source§impl FileError
impl FileError
Sourcepub fn new(path: impl Into<PathBuf>, message: impl Into<String>) -> Self
pub fn new(path: impl Into<PathBuf>, message: impl Into<String>) -> Self
Create a new file error with path and message.
Sourcepub fn at_location(self, line: u32, column: u32) -> Self
pub fn at_location(self, line: u32, column: u32) -> Self
Add line and column location information.
Sourcepub fn with_code(self, code: impl Into<String>) -> Self
pub fn with_code(self, code: impl Into<String>) -> Self
Add an error code for programmatic handling.
Sourcepub fn from_parse_error(path: impl Into<PathBuf>, error: impl Display) -> Self
pub fn from_parse_error(path: impl Into<PathBuf>, error: impl Display) -> Self
Convert from a parse error with context.
Sourcepub fn from_analysis_error(
path: impl Into<PathBuf>,
error: &AnalysisError,
) -> Self
pub fn from_analysis_error( path: impl Into<PathBuf>, error: &AnalysisError, ) -> Self
Convert from an AnalysisError with path context.
Trait Implementations§
impl Eq for FileError
Source§impl Error for FileError
impl Error for FileError
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 From<FileError> for AnalysisError
impl From<FileError> for AnalysisError
impl StructuralPartialEq for FileError
Auto Trait Implementations§
impl Freeze for FileError
impl RefUnwindSafe for FileError
impl Send for FileError
impl Sync for FileError
impl Unpin for FileError
impl UnsafeUnpin for FileError
impl UnwindSafe for FileError
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> EnsureExt<T> for T
impl<T> EnsureExt<T> for T
Source§fn ensure<P, E>(self, predicate: P, error: E) -> Validation<T, NonEmptyVec<E>>where
P: Predicate<T>,
fn ensure<P, E>(self, predicate: P, error: E) -> Validation<T, NonEmptyVec<E>>where
P: Predicate<T>,
Validate that this value satisfies the given predicate. Read more
Source§fn ensure_with<P, E, F>(
self,
predicate: P,
error_fn: F,
) -> Validation<T, NonEmptyVec<E>>
fn ensure_with<P, E, F>( self, predicate: P, error_fn: F, ) -> Validation<T, NonEmptyVec<E>>
Validate with an error-generating function. Read more
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more