git-ents.gitmain
⌘K
foforge
error.rs34 lines · 1.3 KB · rusthistorycomment on this file
1//! The error type every `ents-model` operation returns.
2
3/// Everything that can go wrong building or parsing `ents-model` values.
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6 /// A namespace builder (`namespace::member_ref` and friends) composed a
7 /// refname that gitoxide's own refname validation rejects — for example,
8 /// an id containing `..` or a disallowed control character. The caller
9 /// should reject the offending id before offering it to a namespace
10 /// builder.
11 #[error("invalid refname {name:?}: {source}")]
12 InvalidRefName {
13 /// The composed refname that failed validation.
14 name: String,
15 /// gitoxide's own refname validation error.
16 #[source]
17 source: gix::validate::reference::name::Error,
18 },
19
20 /// A value handed to one of this crate's `FromStr` implementations
21 /// (for example, [`crate::claim::Verdict`]'s kebab-case parse) did not
22 /// match any known form.
23 #[error("invalid argument: {0}")]
24 InvalidArgument(String),
25
26 /// A [`crate::Claim`]'s binding could not be serialized into or
27 /// deserialized from the object store
28 /// ([`crate::claim::Claim::new`], [`crate::claim::Claim::binding`]).
29 #[error("binding operation failed: {0}")]
30 Anchor(#[from] ents_anchor::Error),
31}
32
33/// The `Result` alias every `ents-model` operation returns.
34pub type Result<T> = std::result::Result<T, Error>;