elixirmoney / money

Elixir library for working with Money safer, easier, and fun... Is an interpretation of the Fowler's Money pattern in fun.prog.
https://hex.pm/packages/money/
MIT License
826 stars 139 forks source link

Improves error message when Money.parse! fails #141

Closed michelboaventura closed 4 years ago

michelboaventura commented 4 years ago

The current error message isn't helpful because it doesn't show the full context to help debug the problem. For example, in a trace like:

15:15:11.921 [error] GenServer Foo terminating
** (ArgumentError) unable to parse "0.100000"
    (money 1.7.0) lib/money.ex:213: Money.parse!/3

it is hard to figure out that the problem is that we are using an invalid currency. With this commit the above error becomes:

15:15:11.921 [error] GenServer Foo terminating
** (ArgumentError) unable to parse "0.100000" with currency :FOO
    (money 1.7.0) lib/money.ex:213: Money.parse!/3

which hopefully will make debug a little bit easier.

Nitrino commented 4 years ago

Cool work, thanks! 🔥