Skip to content

fix: replace panics with errors in ECB response handling#189

Merged
jczaja merged 1 commit intomainfrom
sfraczek/fix-ecb-panics
Apr 20, 2026
Merged

fix: replace panics with errors in ECB response handling#189
jczaja merged 1 commit intomainfrom
sfraczek/fix-ecb-panics

Conversation

@sfraczek
Copy link
Copy Markdown
Collaborator

@sfraczek sfraczek commented Apr 18, 2026

Replace panic! with Error in ecb response handling

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes panic-based handling in the ECB exchange-rate fetch/parsing path and instead propagates failures as Result errors, improving robustness for callers.

Changes:

  • Replace .expect(...)/.unwrap() with ? + contextual map_err(...) in get_eur_to_usd_exchange_rate.
  • Replace assert_eq! currency validations with explicit Err(...) returns when the ECB response schema doesn’t match expectations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ecb.rs
}
if ecb_response.currency_denom != "EUR" {
return Err(format!(
"Unexpected ECB currency_denom: {}, expected EUR",
@sfraczek sfraczek requested a review from jczaja April 18, 2026 17:54
Copy link
Copy Markdown
Collaborator

@jczaja jczaja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jczaja jczaja merged commit 1ee78ce into main Apr 20, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants