Print debugging info if a pod does not verify (#141)
* Print debugging info if a pod does not verify * Use logging for incorrect pods; add additional test
This commit is contained in:
parent
22db6ce4c6
commit
fee70af12b
4 changed files with 111 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
use std::fmt;
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use log::error;
|
||||
|
||||
use super::{CustomPredicateRef, NativePredicate, Statement, StatementArg};
|
||||
use crate::middleware::{AnchoredKey, Params, Predicate, Value, SELF};
|
||||
|
|
@ -308,6 +309,15 @@ impl Operation {
|
|||
.map(|(pred, st_args)| Statement::from_args(pred, st_args));
|
||||
x.transpose()
|
||||
}
|
||||
/// Checks the given operation against a statement, and prints information if the check does not pass
|
||||
pub fn check_and_log(&self, params: &Params, output_statement: &Statement) -> Result<bool> {
|
||||
let valid: bool = self.check(params, output_statement)?;
|
||||
if !valid {
|
||||
error!("Check failed on the following statement");
|
||||
error!("{}", output_statement);
|
||||
}
|
||||
Ok(valid)
|
||||
}
|
||||
/// Checks the given operation against a statement.
|
||||
pub fn check(&self, _params: &Params, output_statement: &Statement) -> Result<bool> {
|
||||
use Statement::*;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue