Skip to content

Commit 011a148

Browse files
authored
Merge pull request #9 from bodo-run/docstring
fix
2 parents 8ed5e5f + 771f46e commit 011a148

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

src/lib.rs

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,14 @@ fn generate_parse_info_impl(
134134
}
135135

136136
fn __inline_find_config(base_name: &str, fmts: &[&str]) -> Option<std::path::PathBuf> {
137-
let mut dir = std::env::current_dir().ok()?;
137+
let mut dir = match std::env::current_dir() {
138+
Ok(dir) => dir,
139+
Err(e) => {
140+
eprintln!("Warning: Failed to get current directory for config discovery: {}", e);
141+
eprintln!("Config file discovery will be skipped");
142+
return None;
143+
}
144+
};
138145
let mut found: Option<std::path::PathBuf> = None;
139146

140147
loop {
@@ -209,15 +216,23 @@ fn generate_parse_info_impl(
209216
}
210217
}
211218

212-
let built = config_data.build().unwrap_or_else(|e| {
213-
eprintln!("Failed to build config: {}", e);
214-
::config::Config::default()
215-
});
216-
let ephemeral_cfg: #cfg_ident = built.clone().try_deserialize().unwrap_or_else(|e| {
217-
eprintln!("Failed to deserialize config into struct: {}", e);
218-
eprintln!("Config data after build: {:#?}", built);
219-
#cfg_ident::default()
220-
});
219+
let built = match config_data.build() {
220+
Ok(config) => config,
221+
Err(e) => {
222+
eprintln!("Warning: Failed to build config: {}", e);
223+
eprintln!("Continuing with default configuration");
224+
::config::Config::default()
225+
}
226+
};
227+
let ephemeral_cfg: #cfg_ident = match built.clone().try_deserialize() {
228+
Ok(cfg) => cfg,
229+
Err(e) => {
230+
eprintln!("Warning: Failed to deserialize config into struct: {}", e);
231+
eprintln!("Config data after build: {:#?}", built);
232+
eprintln!("Continuing with default configuration");
233+
#cfg_ident::default()
234+
}
235+
};
221236

222237

223238
let final_struct = #struct_ident {

0 commit comments

Comments
 (0)