Skip to content

Commit

Permalink
Report errors correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsnaps committed Jul 11, 2024
1 parent 35a1365 commit f9c799b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ impl TryFrom<&PatternExpression> for Expression {
}
// ValueType::Bool => {}
// ValueType::Timestamp => {}
_ => todo!("Still needs support for values of type `{cel_type}`"),
_ => Err(format!(
"Still needs support for values of type `{cel_type}`"
)),
}?;

match expression.operator {
Expand Down
18 changes: 10 additions & 8 deletions src/filter/root_context.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::configuration::{FilterConfig, PluginConfiguration};
use crate::filter::http_context::Filter;
use const_format::formatcp;
use log::{debug, info, warn};
use log::{debug, error, info};
use proxy_wasm::traits::{Context, HttpContext, RootContext};
use proxy_wasm::types::ContextType;
use std::rc::Rc;
Expand Down Expand Up @@ -53,16 +53,18 @@ impl RootContext for FilterRoot {
match serde_json::from_slice::<PluginConfiguration>(&configuration) {
Ok(config) => {
info!("plugin config parsed: {:?}", config);
let result = config.try_into();
if result.is_err() {
warn!("failed to compile plugin config");
return false;
}
let filter_config: FilterConfig = result.unwrap();
let filter_config =
match <PluginConfiguration as TryInto<FilterConfig>>::try_into(config) {
Ok(cfg) => cfg,
Err(err) => {
error!("failed to compile plugin config: {}", err);
return false;
}
};
self.config = Rc::new(filter_config);
}
Err(e) => {
warn!("failed to parse plugin config: {}", e);
error!("failed to parse plugin config: {}", e);
return false;
}
}
Expand Down

0 comments on commit f9c799b

Please sign in to comment.