Please check the functions on the Exception module for formatting exceptions into messages using different formats and arguments.
On Wed, Dec 7, 2016 at 09:18 Louis Pop <[email protected]> wrote: > What's the reason for not using inspect? > > On Wed, 7 Dec 2016, 02:59 Allen Madsen, <[email protected]> wrote: > > Hi all, > > I was trying to log an exception and noticed that this does not work: > Logger.error(exception). Logger could handle this case itself, but I > think it would be better to handle it more generically. > > So, I propose when a module uses the defexception macro, that Elixir > automatically define the String.Chars implementation for that module. > Inside the defexception macro, the implementation of String.Chars would > be the following: > > defimpl String.Chars, for: env.module do > def to_string(error), do: Exception.format(:error, error) > end > > -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elixir-lang-core/88a99607-d4ea-472c-bd1a-48dee887f5e8%40googlegroups.com > <https://groups.google.com/d/msgid/elixir-lang-core/88a99607-d4ea-472c-bd1a-48dee887f5e8%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > > -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elixir-lang-core/CAM-pwt5bnVvpeJd%2BKdu_PmQvPRF-3ZKDFH6Bb%2BH5q-i6TamAAQ%40mail.gmail.com > <https://groups.google.com/d/msgid/elixir-lang-core/CAM-pwt5bnVvpeJd%2BKdu_PmQvPRF-3ZKDFH6Bb%2BH5q-i6TamAAQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2B1tECy%2BSWBCKCwQi5KNaJ2%3Dg4stu87HouOxBU5M%3DxttQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
