oxicode_agent/issues/error.rs
1//! Errors returned by issue operations.
2
3use std::io;
4
5use chrono::{DateTime, Utc};
6use thiserror::Error;
7
8/// Errors returned by issue operations.
9///
10/// Kept as a small typed enum (per AGENTS.md: application crate uses anyhow
11/// broadly, but these specific variants are useful to distinguish for the
12/// agent tool layer and tests).
13#[derive(Debug, Error)]
14pub enum IssueError {
15 /// `content_hash` supplied did not match the current on-disk content.
16 /// The caller should re-read and retry.
17 #[error("issue #{id} was modified since last read; re-read and retry")]
18 Conflict {
19 /// Id of the modified issue.
20 id: u32,
21 },
22
23 /// Another live session holds the assignment for this issue.
24 #[error("issue #{id} is currently being worked on by session {owner}")]
25 Assigned {
26 /// Id of the contended issue.
27 id: u32,
28 /// Session id currently holding the assignment.
29 owner: String,
30 /// When the current assignment was taken.
31 acquired_at: DateTime<Utc>,
32 },
33
34 /// The caller does not hold the assignment required for this mutation.
35 #[error("issue #{id} is not assigned to session {caller}; run `start` first")]
36 NotAssigned {
37 /// Id of the issue being mutated.
38 id: u32,
39 /// Session id that attempted the mutation.
40 caller: String,
41 },
42
43 /// Issue id not found.
44 #[error("issue #{id} not found")]
45 NotFound {
46 /// Id that could not be resolved.
47 id: u32,
48 },
49
50 /// Underlying I/O failure.
51 #[error(transparent)]
52 Io(#[from] io::Error),
53
54 /// Any other failure.
55 #[error(transparent)]
56 Other(#[from] anyhow::Error),
57}