evaluator: give a fn to handle strategy errors

This commit is contained in:
Graham Christensen 2019-03-22 13:48:48 -04:00
parent 3b4117e6eb
commit 795ace48df
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C

View file

@ -7,6 +7,7 @@ use crate::maintainers;
use crate::maintainers::ImpactedMaintainers; use crate::maintainers::ImpactedMaintainers;
use amqp::protocol::basic::{BasicProperties, Deliver}; use amqp::protocol::basic::{BasicProperties, Deliver};
use hubcaps; use hubcaps;
use hubcaps::gists::Gists;
use hubcaps::issues::Issue; use hubcaps::issues::Issue;
use ofborg::acl::ACL; use ofborg::acl::ACL;
use ofborg::checkout; use ofborg::checkout;
@ -29,6 +30,7 @@ use std::path::Path;
use std::path::PathBuf; use std::path::PathBuf;
use std::time::Instant; use std::time::Instant;
use tasks::eval; use tasks::eval;
use tasks::eval::StepResult;
use uuid::Uuid; use uuid::Uuid;
pub struct EvaluationWorker<E> { pub struct EvaluationWorker<E> {
@ -89,6 +91,26 @@ impl<E: stats::SysEvents> EvaluationWorker<E> {
update_labels(&issue, &tagger.tags_to_add(), &tagger.tags_to_remove()); 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<E: stats::SysEvents + 'static> worker::SimpleWorker for EvaluationWorker<E> { impl<E: stats::SysEvents + 'static> worker::SimpleWorker for EvaluationWorker<E> {