Skip to main content

oxi/store/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 { id: u32 },
19
20    /// Another live session holds the assignment for this issue.
21    #[error("issue #{id} is currently being worked on by session {owner}")]
22    Assigned {
23        id: u32,
24        owner: String,
25        acquired_at: DateTime<Utc>,
26    },
27
28    /// The caller does not hold the assignment required for this mutation.
29    #[error("issue #{id} is not assigned to session {caller}; run `start` first")]
30    NotAssigned { id: u32, caller: String },
31
32    /// Issue id not found.
33    #[error("issue #{id} not found")]
34    NotFound { id: u32 },
35
36    #[error(transparent)]
37    Io(#[from] io::Error),
38
39    #[error(transparent)]
40    Other(#[from] anyhow::Error),
41}