Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

templates: use inspect/1 instead of to_string/1 in errors_on/1 #5864

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

v0idpwn
Copy link

@v0idpwn v0idpwn commented Jul 9, 2024

Per elixir-ecto/ecto#4445

I don't see a reason to prefer to_string over inspect here, maybe I'm missing something :)

@viniciussbs
Copy link

So, I've tried inspect/1 in a custom errors_on/1 implementation in my code base. I gave up because decimal values get weird representation when interpolated using inspect/1:

iex(1)> to_string(Decimal.new(0))
"0"
iex(2)> inspect(Decimal.new(0))
"Decimal.new(\"0\")"

@v0idpwn
Copy link
Author

v0idpwn commented Jul 9, 2024

Considering this function is built for testing, one could would argue that Decimal.new("0") is a more precise depiction of the data for the error message than 0.

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.

2 participants