radicle_job/error.rs
1//! Errors that are captured for job related actions.
2
3use radicle::{cob, git};
4use thiserror::Error;
5
6/// Errors that can occur when building a [`Job`][job].
7///
8/// [job]: super::Job
9#[derive(Debug, Error)]
10pub enum Build {
11 /// The initial action in the history of the [`Job`][job] was not a
12 /// [`Request`][req].
13 ///
14 /// [job]: super::Job
15 /// [req]: super::Action::Request
16 #[error("initial action of job must request an OID")]
17 Initial,
18 /// The [`Request`][req] referred to a commit that could not be found.
19 ///
20 /// [req]: super::Action::Request
21 #[error("missing commit for job run {oid}: {err}")]
22 MissingCommit {
23 /// The [`Oid`][oid] of the commit that was requested, but is missing.
24 ///
25 /// [oid]: git::Oid
26 oid: git::Oid,
27 /// The underlying error from Git that occurred.
28 #[source]
29 err: git::raw::Error,
30 },
31}
32
33/// Errors that can occur when applying an [`Entry`][entry] to the [`Job`][job]
34/// collaborative object.
35///
36/// [entry]: radicle::cob::Entry
37/// [job]: super::Job
38#[derive(Debug, Error)]
39pub enum Apply {
40 /// Applying the entry resulted in a [`Build`] error.
41 #[error(transparent)]
42 Build(#[from] Build),
43 /// Error occurred when decoding an [`Entry`][entry] into an [`Op`][op].
44 ///
45 /// [entry]: radicle::cob::Entry
46 /// [op]: radicle::cob::Op
47 #[error(transparent)]
48 Op(#[from] cob::op::OpEncodingError),
49}