use crate::error::TemplateError;
use crate::template::attempt_exception_reporter::AttemptExceptionReporter;
pub struct LoggingAttemptExceptionReporter;
impl AttemptExceptionReporter for LoggingAttemptExceptionReporter {
fn report_exception(&self, _error: &TemplateError) {
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn report_exception_is_silent() {
let reporter = LoggingAttemptExceptionReporter;
let err = TemplateError::misc("simulated attempt error");
reporter.report_exception(&err);
reporter.report_exception(&TemplateError::type_mismatch("string", "number"));
}
#[test]
fn trait_object_dispatch() {
let reporter: Box<dyn AttemptExceptionReporter> = Box::new(LoggingAttemptExceptionReporter);
let err = TemplateError::misc("caught by attempt");
reporter.report_exception(&err);
}
}