ash-project / splode

Aggregatable and consistent errors for Elixir
MIT License
15 stars 4 forks source link

Fix Splode.Error.message/1 #7

Closed jechol closed 5 months ago

jechol commented 5 months ago

Contributor checklist

zachdaniel commented 5 months ago

I think we should do something like "if to string is implemented, to string, else inspect"

jechol commented 5 months ago

For example, when investigated using String.Chars.impl_for/1 both [] and [:a] return String.Chars.List, but while [] can be converted to a string using to_string, [:a] cannot. I think it's always better to use inspect for the following two reasons:

  1. It is possible to use a try block to attempt to_string and fall back to inspect if it fails, but it feels a bit awkward.
  2. It feels more consistent to always use inspect rather than having to_string and inspect separated based on the type.

I'm curious about your opinion.

zachdaniel commented 5 months ago

You're right :) I was thinking that this might somehow surface to end users, but that we don't use message/1 for displaying to the outside world.