From 4dbaad7fda5a91542b9b70d705597e173ea0cc8a Mon Sep 17 00:00:00 2001 From: Tyler McMullen Date: Mon, 13 Jan 2025 12:19:42 -0800 Subject: [PATCH] Clean up some printlns and explain eating the expression errors. --- esi/src/expression.rs | 5 ++++- esi/src/lib.rs | 6 ++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/esi/src/expression.rs b/esi/src/expression.rs index 1ac6ebd..6837f24 100644 --- a/esi/src/expression.rs +++ b/esi/src/expression.rs @@ -1,5 +1,6 @@ use fastly::http::Method; use fastly::Request; +use log::debug; use regex::RegexBuilder; use std::fmt::Write; use std::iter::Peekable; @@ -15,7 +16,9 @@ pub fn try_evaluate_interpolated( ) -> Option { evaluate_interpolated(cur, ctx) .map_err(|e| { - println!("Error while evaluating interpolated expression: {e}"); + // We eat the error here because a failed expression should result in an empty result + // and not prevent the rest of the file from processing. + debug!("Error while evaluating interpolated expression: {e}"); }) .ok() } diff --git a/esi/src/lib.rs b/esi/src/lib.rs index 8ead165..31aaf29 100644 --- a/esi/src/lib.rs +++ b/esi/src/lib.rs @@ -528,9 +528,7 @@ fn event_receiver( queue.push_back(Element::Raw(result.to_string().into_bytes())); } } - Event::ESI(Tag::When { .. }) => { - println!("Shouldn't be possible to get a When tag here"); - } + Event::ESI(Tag::When { .. }) => unreachable!(), Event::ESI(Tag::Choose { when_branches, otherwise_events, @@ -557,7 +555,7 @@ fn event_receiver( break; } } else { - println!("Somehow got something other than a When in a Choose: {when:?}",); + unreachable!() } }