diff --git a/lib/elixir/lib/exception.ex b/lib/elixir/lib/exception.ex index fab8051949b..8aeb2f52c77 100644 --- a/lib/elixir/lib/exception.ex +++ b/lib/elixir/lib/exception.ex @@ -2718,7 +2718,7 @@ defmodule ErlangError do {:ok, reason, IO.iodata_to_binary([":\n\n" | Enum.map(args_errors, &arg_error/1)])} general = extra[:general] -> - {:ok, reason, ": " <> general} + {:ok, reason, ": " <> IO.chardata_to_string(general)} true -> :error diff --git a/lib/elixir/test/elixir/exception_test.exs b/lib/elixir/test/elixir/exception_test.exs index ef9cb322e23..36d6377f0c1 100644 --- a/lib/elixir/test/elixir/exception_test.exs +++ b/lib/elixir/test/elixir/exception_test.exs @@ -50,6 +50,12 @@ defmodule ExceptionTest do {:io, :put_chars, [self(), <<222>>], [error_info: %{module: __MODULE__, function: :dummy_error_extras}]} ]) + + assert %ErlangError{original: {:failed_load_cacerts, :enoent}, reason: ": this is chardata"} = + Exception.normalize(:error, {:failed_load_cacerts, :enoent}, [ + {:pubkey_os_cacerts, :get, 0, + [error_info: %{module: __MODULE__, function: :dummy_error_chardata}]} + ]) end test "format/2 without stacktrace" do @@ -1066,4 +1072,8 @@ defmodule ExceptionTest do end def dummy_error_extras(_exception, _stacktrace), do: %{general: "foo"} + + def dummy_error_chardata(_exception, _stacktrace) do + %{general: ~c"this is " ++ [~c"chardata"], reason: ~c"this " ++ [~c"too"]} + end end