Skip to content
This repository was archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
improve error handling so that the bot is able to post comments about…
Browse files Browse the repository at this point in the history
… errors
  • Loading branch information
joao-paulo-parity committed Oct 9, 2021
1 parent 8e9ea6e commit c64a12a
Show file tree
Hide file tree
Showing 5 changed files with 752 additions and 690 deletions.
2 changes: 1 addition & 1 deletion src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ fn handle_cmd_result<'a>(
err_output.replace(secret, "${SECRET}");
}
}
log::error!(
log::info!(
"handle_cmd_result: {} failed with error: {}",
cmd_display,
err_output
Expand Down
14 changes: 9 additions & 5 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ pub enum Error {
actual: String,
},

#[snafu(display("Error getting process info: {}", source))]
ProcessFile {
source: Box<Error>,
},

#[snafu(display("Missing process info."))]
ProcessInfo {
errors: Option<Vec<String>>,
Expand Down Expand Up @@ -207,6 +202,15 @@ impl Error {
},
}
}
pub fn stops_merge_attempt(&self) -> bool {
match self {
Self::WithIssue { source, .. } | Self::Merge { source, .. } => {
source.stops_merge_attempt()
}
Self::MergeFailureWillBeSolvedLater { .. } => false,
_ => true,
}
}
}

impl From<curl::Error> for Error {
Expand Down
10 changes: 4 additions & 6 deletions src/github.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::{
error::*, utils::parse_bot_comment_from_text, Result, PR_HTML_URL_REGEX,
error::*, utils::parse_bot_comment_from_text,
PlaceholderDeserializationItem, Result, PR_HTML_URL_REGEX,
};
use regex::Regex;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -73,7 +74,7 @@ pub struct Issue {
// User might be missing when it has been deleted
pub user: Option<User>,
pub body: Option<String>,
pub pull_request: Option<IssuePullRequest>,
pub pull_request: Option<PlaceholderDeserializationItem>,
pub repository: Option<Repository>,
pub repository_url: Option<String>,
}
Expand Down Expand Up @@ -172,9 +173,6 @@ pub struct Team {
pub id: i64,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct IssuePullRequest {}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Head {
pub label: Option<String>,
Expand Down Expand Up @@ -354,7 +352,7 @@ pub struct WebhookIssueComment {
pub number: i64,
pub html_url: String,
pub repository_url: Option<String>,
pub pull_request: Option<IssuePullRequest>,
pub pull_request: Option<PlaceholderDeserializationItem>,
}

impl HasIssueDetails for WebhookIssueComment {
Expand Down
11 changes: 11 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use serde::{Deserialize, Serialize};

mod auth;
pub mod bamboo;
pub mod cmd;
Expand Down Expand Up @@ -43,3 +45,12 @@ pub enum CommentCommand {
BurninRequest,
CompareReleaseRequest,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PlaceholderDeserializationItem {}

pub enum MergeCancelOutcome {
ShaDidNotExist,
WasCancelled,
WasNotCancelled,
}
Loading

0 comments on commit c64a12a

Please sign in to comment.