Skip to content

Commit 4e19ad8

Browse files
committed
improve error messages
1 parent d1debb5 commit 4e19ad8

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ fn main() {
7878
fn parse_openapi_specs(spec: &Vec<PathBuf>) -> Vec<OpenAPI> {
7979
spec.into_iter()
8080
.map(|spec| {
81-
let file = File::open(&spec).unwrap();
81+
let file =
82+
File::open(&spec).expect(format!("Could not open file: {:?}", spec).as_str());
8283
let reader = BufReader::new(file);
8384
let openapi: OpenAPI = serde_yaml::from_reader(reader)
8485
.expect(format!("Could not deserialize input: {:?}", spec).as_str());

src/merger.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,17 @@ fn merge_unique<Key, Item>(
228228
) -> Result<IndexMap<Key, Item>>
229229
where
230230
Key: std::fmt::Debug + Eq + std::hash::Hash,
231-
Item: PartialEq,
231+
Item: std::fmt::Debug + PartialEq,
232232
{
233233
for (key, value) in b {
234234
match a.entry(key) {
235235
indexmap::map::Entry::Occupied(entry) => {
236236
if entry.get() != &value {
237237
return Err(Error::unexpected(format!(
238-
"Duplicate key {:?} with different values",
239-
entry.key()
238+
"Duplicate key {:?} with different values \n Current {:?} \n New {:?}",
239+
entry.key(),
240+
entry.get(),
241+
value
240242
)));
241243
}
242244
}

0 commit comments

Comments
 (0)