cli: Log errors when COBs can't load

This commit is contained in:
cloudhead 2024-08-09 10:46:45 +02:00
parent 2b75045661
commit bfc949d094
No known key found for this signature in database
4 changed files with 27 additions and 9 deletions

View File

@ -306,9 +306,13 @@ where
} = match &n.kind { } = match &n.kind {
NotificationKind::Branch { name } => NotificationRow::branch(name, head, &n, &repo)?, NotificationKind::Branch { name } => NotificationRow::branch(name, head, &n, &repo)?,
NotificationKind::Cob { typed_id } => { NotificationKind::Cob { typed_id } => {
match NotificationRow::cob(typed_id, &n, &issues, &patches, &repo)? { match NotificationRow::cob(typed_id, &n, &issues, &patches, &repo) {
Some(row) => row, Ok(Some(row)) => row,
None => continue, Ok(None) => continue,
Err(e) => {
log::error!(target: "cli", "Error loading notification for {typed_id}: {e}");
continue;
}
} }
} }
NotificationKind::Unknown { refname } => { NotificationKind::Unknown { refname } => {

View File

@ -632,9 +632,13 @@ where
let mut all = Vec::new(); let mut all = Vec::new();
let issues = cache.list()?; let issues = cache.list()?;
for result in issues { for result in issues {
let Ok((id, issue)) = result else { let (id, issue) = match result {
Ok((id, issue)) => (id, issue),
Err(e) => {
// Skip issues that failed to load. // Skip issues that failed to load.
log::error!(target: "cli", "Issue load error: {e}");
continue; continue;
}
}; };
if let Some(a) = assignee { if let Some(a) = assignee {

View File

@ -29,9 +29,13 @@ pub fn run(
None => patches.list()?, None => patches.list()?,
}; };
for patch in iter { for patch in iter {
let Ok((id, patch)) = patch else { let (id, patch) = match patch {
Ok((id, patch)) => (id, patch),
Err(e) => {
// Skip patches that failed to load. // Skip patches that failed to load.
log::error!(target: "cli", "Patch load error: {e}");
continue; continue;
}
}; };
if !authors.is_empty() { if !authors.is_empty() {
if !authors.contains(patch.author().id()) { if !authors.contains(patch.author().id()) {

View File

@ -29,6 +29,12 @@ pub struct TypedId {
pub type_name: TypeName, pub type_name: TypeName,
} }
impl std::fmt::Display for TypedId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}/{}", self.type_name, self.id)
}
}
/// Errors that occur when parsing a Git refname into a [`TypedId`]. /// Errors that occur when parsing a Git refname into a [`TypedId`].
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
pub enum ParseIdentifierError { pub enum ParseIdentifierError {