crates/cli/ents-lens/src/error.rs
error.rshistorycomment on this file
| 1 | //! The lens's error type: every failure a request handler can hit while |
| 2 | //! reading `refs/meta/*`, projecting an anchor, or writing a new comment. |
| 3 | |
| 4 | /// A lens operation's result. |
| 5 | pub type Result<T> = std::result::Result<T, Error>; |
| 6 | |
| 7 | /// Everything that can go wrong deriving a lens response or composing a |
| 8 | /// comment through it. |
| 9 | #[derive(Debug, thiserror::Error)] |
| 10 | pub enum Error { |
| 11 | /// A comment read, listing, projection, or mutation failed in the |
| 12 | /// shared `ents-forge` library the lens calls (`lens.parity`). The |
| 13 | /// caller should surface the message; it is never a protocol-level |
| 14 | /// fault. |
| 15 | #[error(transparent)] |
| 16 | Forge(#[from] ents_forge::Error), |
| 17 | |
| 18 | /// The repository could not be opened at the injected path — the lens |
| 19 | /// was wired against a directory that is not a git working tree. |
| 20 | #[error("open repository: {0}")] |
| 21 | Repo(String), |
| 22 | |
| 23 | /// A filesystem operation on the compose template under `.git/` |
| 24 | /// (`lens.compose`) failed. The caller should report it; the comment |
| 25 | /// was not created. |
| 26 | #[error("template {path}: {source}")] |
| 27 | Template { |
| 28 | /// The template path the operation targeted. |
| 29 | path: std::path::PathBuf, |
| 30 | /// The underlying IO error. |
| 31 | source: std::io::Error, |
| 32 | }, |
| 33 | |
| 34 | /// An `executeCommand` request named a command the lens exposes but |
| 35 | /// carried the wrong arguments (a missing or non-string comment id, for |
| 36 | /// instance). The caller sent a malformed request. |
| 37 | #[error("bad command arguments: {0}")] |
| 38 | BadArguments(String), |
| 39 | } |
| 40 | |
| 41 | impl From<gix::open::Error> for Error { |
| 42 | fn from(source: gix::open::Error) -> Self { |
| 43 | Self::Repo(source.to_string()) |
| 44 | } |
| 45 | } |