Zsombor Gegesy commited on
Commit
8ed4c9e
1 Parent(s): 32abacb

Propagate errors upward, if an engine can't be initialized

Browse files
Files changed (1) hide show
  1. src/config/parser.rs +4 -3
src/config/parser.rs CHANGED
@@ -3,6 +3,7 @@
3
 
4
  use crate::handler::paths::{file_path, FileType};
5
 
 
6
  use crate::models::parser_models::{AggregatorConfig, RateLimiter, Style};
7
  use log::LevelFilter;
8
  use mlua::Lua;
@@ -28,7 +29,7 @@ pub struct Config {
28
  /// It stores the option to whether enable or disable debug mode.
29
  pub debug: bool,
30
  /// It stores all the engine names that were enabled by the user.
31
- pub upstream_search_engines: Vec<crate::models::engine_models::EngineHandler>,
32
  /// It stores the time (secs) which controls the server request timeout.
33
  pub request_timeout: u8,
34
  /// It stores the number of threads which controls the app will use to run.
@@ -111,8 +112,8 @@ impl Config {
111
  .get::<_, HashMap<String, bool>>("upstream_search_engines")?
112
  .into_iter()
113
  .filter_map(|(key, value)| value.then_some(key))
114
- .filter_map(|engine| crate::models::engine_models::EngineHandler::new(&engine).ok())
115
- .collect(),
116
  request_timeout: globals.get::<_, u8>("request_timeout")?,
117
  threads,
118
  rate_limiter: RateLimiter {
 
3
 
4
  use crate::handler::paths::{file_path, FileType};
5
 
6
+ use crate::models::engine_models::{EngineError, EngineHandler};
7
  use crate::models::parser_models::{AggregatorConfig, RateLimiter, Style};
8
  use log::LevelFilter;
9
  use mlua::Lua;
 
29
  /// It stores the option to whether enable or disable debug mode.
30
  pub debug: bool,
31
  /// It stores all the engine names that were enabled by the user.
32
+ pub upstream_search_engines: Vec<EngineHandler>,
33
  /// It stores the time (secs) which controls the server request timeout.
34
  pub request_timeout: u8,
35
  /// It stores the number of threads which controls the app will use to run.
 
112
  .get::<_, HashMap<String, bool>>("upstream_search_engines")?
113
  .into_iter()
114
  .filter_map(|(key, value)| value.then_some(key))
115
+ .map(|engine| EngineHandler::new(&engine))
116
+ .collect::<Result<Vec<EngineHandler>, error_stack::Report<EngineError>>>()?,
117
  request_timeout: globals.get::<_, u8>("request_timeout")?,
118
  threads,
119
  rate_limiter: RateLimiter {