Question: why this unwrap throws?
Open
Nobody has claimed this yet.
C-bug
E-help-wanted
- Dominant language
- Rust
- Stars
- 3.2k
- Forks
- 265
- Avg merge
- 2h 42m
- Merged PRs (30d)
- 4
Description
extern crate config;
use std::collections::HashMap;
fn main() {
let mut settings = config::Config::default();
let file = config::File::with_name("bla");
{
let result = settings.merge(file);
match result {
Ok(_) => (),
Err(e) => {
println!("{:?}",e);
println!("Failed to read the settings file, skipping...");
}
}
}
settings.merge(config::Environment::with_prefix("bla")).unwrap();
println!("{:?}", settings.try_into::<HashMap<String, String>>().unwrap());
}
The Environment::with_prefix unwrap panics. Why does it? Output:
configuration file "bla" not found
Failed to read the settings file, skipping...
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: configuration file "bla" not found', src\libcore\result.rs:906:4
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: process didn't exit successfully: `target\debug\vault-unseal.exe` (exit code: 101)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the settings.merge(config::Environment::with_prefix("bla")) call and compare it with the earlier matched merge result. Reproduce the missing-configuration case and determine what error handling the issue should document or change; completion requires a clear explanation of why the unwrap receives an error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100