Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

ethers::utils::parse_units panics on unknown units #690

Closed
MartinquaXD opened this issue Dec 14, 2021 · 0 comments · Fixed by #691
Closed

ethers::utils::parse_units panics on unknown units #690

MartinquaXD opened this issue Dec 14, 2021 · 0 comments · Fixed by #691
Labels
bug Something isn't working

Comments

@MartinquaXD
Copy link

Version
0.6.0

Platform
Linux x13 5.15.6-2-MANJARO #1 SMP PREEMPT Sat Dec 4 11:11:58 UTC 2021 x86_64 GNU/Linux

Description
Calling parse_units with an unknown unit panics.

I tried this code:

ethers::utils::parse_units("1234", "ethe");

Which resulted in:

thread 'main' panicked at 'unrecognized units'

Because the function signature suggests problems are being reported as an error return value, I expected an error instead of a panic.
Please consider returning an error or documenting the panic behavior.

As a side note: If it's possible, please consider making the Error return type implement Send + Sync to improve the ergonomics with error handling crates like anyhow.

@MartinquaXD MartinquaXD added the bug Something isn't working label Dec 14, 2021
meetmangukiya pushed a commit to meetmangukiya/ethers-rs that referenced this issue Mar 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant