#[non_exhaustive]pub enum WorkspaceError {
NotFound {
path: String,
},
VersionConflict(WorkspaceVersionConflict),
RemoteGitConflict(RemoteGitConflict),
InvalidArgument {
message: String,
},
Timeout {
op: String,
duration: Duration,
},
Unsupported(String),
Backend(Error),
}Expand description
Error type returned by every WorkspaceFileSystem
and friend trait method.
#[non_exhaustive] so adding a new variant in a future release is a
minor change — existing match callers compile, they just hit the
catch-all arm for unknown variants.
The variants intentionally split into three categories:
- Structured failures the trait surface knows how to describe
(
NotFound,InvalidArgument,Timeout,Unsupported). New variants in this category should also be structured. - Typed conflicts with their own payload structs that already
ship as part of the public API
(
VersionConflict(WorkspaceVersionConflict),RemoteGitConflict(RemoteGitConflict)). Backend(anyhow::Error)— the escape hatch. Any failure not covered above wraps ananyhow::Error. Backends should prefer the typed variants where they apply;Backendis for genuinely opaque or backend-specific failures.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
NotFound
A read / list against a path that does not exist on the backend.
Backends that distinguish “doesn’t exist” from “exists but
access denied” should still emit this for the former; the
latter belongs in Backend(_) with the backend’s native auth
error wrapped.
Fields
VersionConflict(WorkspaceVersionConflict)
Compare-and-swap write rejected because the in-storage version
no longer matches what the caller observed at read time. Carries
the existing public WorkspaceVersionConflict struct verbatim.
RemoteGitConflict(RemoteGitConflict)
A remote git server returned 409 / 422 with a typed conflict
code (e.g. BRANCH_EXISTS, WORKING_TREE_DIRTY,
NOTHING_TO_STASH). Carries the existing public
RemoteGitConflict struct verbatim.
InvalidArgument
Caller passed an argument the backend cannot honour
(empty version on a CAS write, malformed pattern on a search,
path with parent-traversal, …). Backends should prefer this
over Backend(_) for caller-fault errors so the model can
reason about retry strategy.
Timeout
The operation’s outer timeout (see
WorkspaceServices::operation_timeout)
fired before the backend responded.
Fields
Unsupported(String)
The backend explicitly does not support this operation.
Used by adapters that wrap a partial trait surface (e.g. the
remote git backend rejecting worktree operations even though
WorkspaceGit is implemented).
Backend(Error)
Catch-all wrapping a lower-level error that does not map to one
of the typed variants above. This is the bridge between the
existing anyhow::Result world and the typed surface — when a
backend throws a generic I/O / HTTP / SDK error it ends up here.
Implementations§
Source§impl WorkspaceError
impl WorkspaceError
Sourcepub fn from_anyhow(err: Error) -> Self
pub fn from_anyhow(err: Error) -> Self
Convert an anyhow::Error to a WorkspaceError, preserving
the typed variant when the original cause was one of the
known conflict structs.
Into::into (auto-derived from the #[from] anyhow::Error
variant) drops every anyhow::Error into the Backend arm
because at the value level anyhow::Error has type-erased its
source. Use this helper instead when migrating code paths that
today emit anyhow::Error::new(WorkspaceVersionConflict { .. })
or anyhow::Error::new(RemoteGitConflict { .. }) — the typed
variant survives the round-trip.
// Old code:
fn legacy() -> anyhow::Result<()> { ... }
// New caller:
let typed = WorkspaceError::from_anyhow(legacy().unwrap_err());
match typed {
WorkspaceError::VersionConflict(v) => retry(v),
other => return Err(other),
}Trait Implementations§
Source§impl Debug for WorkspaceError
impl Debug for WorkspaceError
Source§impl Display for WorkspaceError
impl Display for WorkspaceError
Source§impl Error for WorkspaceError
impl Error for WorkspaceError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<Error> for WorkspaceError
impl From<Error> for WorkspaceError
Source§impl From<RemoteGitConflict> for WorkspaceError
impl From<RemoteGitConflict> for WorkspaceError
Source§fn from(source: RemoteGitConflict) -> Self
fn from(source: RemoteGitConflict) -> Self
Source§impl From<WorkspaceVersionConflict> for WorkspaceError
impl From<WorkspaceVersionConflict> for WorkspaceError
Source§fn from(source: WorkspaceVersionConflict) -> Self
fn from(source: WorkspaceVersionConflict) -> Self
Auto Trait Implementations§
impl Freeze for WorkspaceError
impl RefUnwindSafe for WorkspaceError
impl Send for WorkspaceError
impl Sync for WorkspaceError
impl Unpin for WorkspaceError
impl UnsafeUnpin for WorkspaceError
impl UnwindSafe for WorkspaceError
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
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>
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.