I am incorporating Implement extended error information for binary construction by bjorng · Pull Request #5281 · erlang/otp · GitHub, which brings excellent error messages during binary construction, within Elixir.
One limitation is that the format_error/2
callback is using Erlang pretty printing for values, which may not print the terms as expected in Elixir. It would be nice if we could re-use the same message formatting with a custom pretty printer. However, I am not sure how we can customize this.
One option would be to call format_error/3
with additional options, but that can unreasonably extend the surface area of EEP 54. Another option is for me to augment the error_info
map in the stacktrace with a pretty_printer
field, rebuild the head of the stacktrace, and give it to format_error/2
, which Erlang/OTP would look up and use.
Does anyone have other suggestions? I will be glad to send PRs to both EEP 54 and Erlang/OTP once a path is confirmed.
Thank you!