From 795ace48df17805901d42b78f65c93b522e434ba Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Fri, 22 Mar 2019 13:48:48 -0400 Subject: [PATCH] evaluator: give a fn to handle strategy errors --- ofborg/src/tasks/evaluate.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ofborg/src/tasks/evaluate.rs b/ofborg/src/tasks/evaluate.rs index 311fd68..45670e9 100644 --- a/ofborg/src/tasks/evaluate.rs +++ b/ofborg/src/tasks/evaluate.rs @@ -7,6 +7,7 @@ use crate::maintainers; use crate::maintainers::ImpactedMaintainers; use amqp::protocol::basic::{BasicProperties, Deliver}; use hubcaps; +use hubcaps::gists::Gists; use hubcaps::issues::Issue; use ofborg::acl::ACL; use ofborg::checkout; @@ -29,6 +30,7 @@ use std::path::Path; use std::path::PathBuf; use std::time::Instant; use tasks::eval; +use tasks::eval::StepResult; use uuid::Uuid; pub struct EvaluationWorker { @@ -89,6 +91,26 @@ impl EvaluationWorker { update_labels(&issue, &tagger.tags_to_add(), &tagger.tags_to_remove()); } + + fn handle_strategy_err( + &self, + ret: StepResult<()>, + gists: &Gists<'_>, + status: &mut CommitStatus, + ) -> Result<(), ()> { + match ret { + Ok(()) => Ok(()), + Err(eval::Error::Fail(msg)) => { + status.set_with_description(&msg, hubcaps::statuses::State::Failure); + Err(()) + } + Err(eval::Error::FailWithGist(msg, filename, content)) => { + status.set_with_description(&msg, hubcaps::statuses::State::Failure); + status.set_url(make_gist(&gists, &filename, Some("".to_owned()), content)); + Err(()) + } + } + } } impl worker::SimpleWorker for EvaluationWorker {