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:
tideofwords 2025-03-20 10:36:26 -07:00 committed by GitHub
parent 22db6ce4c6
commit fee70af12b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 111 additions and 1 deletions

View file

@ -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::*;