use thiserror::Error;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PostedDiscussion {
pub index: usize,
pub note_id: u64,
pub discussion_id: String,
}
#[derive(Error, Debug)]
pub enum TrvError {
#[error("Git error: {0}")]
Git(#[from] git2::Error),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("JSON serialization error: {0}")]
Serialization(#[from] serde_json::Error),
#[error("Not a repository")]
NotARepository,
#[error(
"This repository uses reftable ref storage, which is not yet supported by libgit2. Re-init with `git init --ref-format=files` or wait for libgit2 reftable support."
)]
ReftableRepository,
#[error("No changes to review")]
NoChanges,
#[error("No comments to export - skipping copy")]
NoComments,
#[error("Review session corrupted: {0}")]
CorruptedSession(String),
#[error("Clipboard error: {0}")]
Clipboard(String),
#[error("VCS command failed: {0}")]
VcsCommand(String),
#[error("Unsupported operation: {0}")]
UnsupportedOperation(String),
#[error("Forge API error: {0}")]
ForgeApi(String),
#[error("Authentication failed: {0}")]
AuthError(String),
#[error("Rate limited")]
RateLimited,
#[error("Resource not found: {0}")]
NotFound(String),
#[error(
"{} of {total} comments posted{approval}; remaining not submitted due to: {cause}",
posted.len(),
total = posted.len() + remaining,
approval = if *approval_posted { " (approval posted)" } else { "" }
)]
PartialReviewSubmit {
posted: Vec<PostedDiscussion>,
remaining: usize,
approval_posted: bool,
#[source]
cause: Box<TrvError>,
},
}
pub type Result<T> = std::result::Result<T, TrvError>;