From 8ed4c9e206b10bdc0d8ae59d160cadc24ada8d53 Mon Sep 17 00:00:00 2001 From: Zsombor Gegesy Date: Sat, 7 Oct 2023 10:31:58 +0200 Subject: [PATCH] Propagate errors upward, if an engine can't be initialized --- src/config/parser.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/config/parser.rs b/src/config/parser.rs index d7202a6..0acdd25 100644 --- a/src/config/parser.rs +++ b/src/config/parser.rs @@ -3,6 +3,7 @@ use crate::handler::paths::{file_path, FileType}; +use crate::models::engine_models::{EngineError, EngineHandler}; use crate::models::parser_models::{AggregatorConfig, RateLimiter, Style}; use log::LevelFilter; use mlua::Lua; @@ -28,7 +29,7 @@ pub struct Config { /// It stores the option to whether enable or disable debug mode. pub debug: bool, /// It stores all the engine names that were enabled by the user. - pub upstream_search_engines: Vec, + pub upstream_search_engines: Vec, /// It stores the time (secs) which controls the server request timeout. pub request_timeout: u8, /// It stores the number of threads which controls the app will use to run. @@ -111,8 +112,8 @@ impl Config { .get::<_, HashMap>("upstream_search_engines")? .into_iter() .filter_map(|(key, value)| value.then_some(key)) - .filter_map(|engine| crate::models::engine_models::EngineHandler::new(&engine).ok()) - .collect(), + .map(|engine| EngineHandler::new(&engine)) + .collect::, error_stack::Report>>()?, request_timeout: globals.get::<_, u8>("request_timeout")?, threads, rate_limiter: RateLimiter {