pub struct EditError {
pub kind: EditErrorKind,
pub message: String,
pub suggestion: Option<String>,
pub similar_targets: Vec<String>,
}Expand description
Structured error type for edit operations with actionable diagnosis.
Fields§
§kind: EditErrorKindWhat kind of error occurred.
message: StringHuman-readable error message.
suggestion: Option<String>A suggestion for how to fix the issue (if available).
similar_targets: Vec<String>Similar targets found in the file (for “did you mean?” hints).
Implementations§
Source§impl EditError
impl EditError
Sourcepub fn new(kind: EditErrorKind, message: impl Into<String>) -> Self
pub fn new(kind: EditErrorKind, message: impl Into<String>) -> Self
Build a structured edit error.
Sourcepub fn guard_rejected(detail: impl Display) -> Error
pub fn guard_rejected(detail: impl Display) -> Error
PathGuard rejection as an anyhow error (edit_error_kind → EditErrorKind::GuardRejected).
Prefer this over [crate::exit::InvalidInputError] for guard failures so
library hosts and CLI JSON can branch on guard_rejected without scraping
English (#1935 / engine PathGuard paths).
Sourcepub fn with_similar(self, similar: Vec<String>) -> Self
pub fn with_similar(self, similar: Vec<String>) -> Self
Attach similar-target suggestions (did-you-mean).
Sourcepub fn with_suggestion(self, suggestion: impl Into<String>) -> Self
pub fn with_suggestion(self, suggestion: impl Into<String>) -> Self
Attach a single suggestion string.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for EditError
impl<'de> Deserialize<'de> for EditError
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Error for EditError
impl Error for EditError
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()
Auto Trait Implementations§
impl Freeze for EditError
impl RefUnwindSafe for EditError
impl Send for EditError
impl Sync for EditError
impl Unpin for EditError
impl UnsafeUnpin for EditError
impl UnwindSafe for EditError
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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 more