Skip to content

Commit c32f725

Browse files
committed
Fix handling of ErlangError when :general key is chardata (elixir-lang#14329)
1 parent 8115bd3 commit c32f725

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Diff for: lib/elixir/lib/exception.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -2530,7 +2530,7 @@ defmodule ErlangError do
25302530
{:ok, reason, IO.iodata_to_binary([":\n\n" | Enum.map(args_errors, &arg_error/1)])}
25312531

25322532
general = extra[:general] ->
2533-
{:ok, reason, ": " <> general}
2533+
{:ok, reason, ": " <> IO.chardata_to_string(general)}
25342534

25352535
true ->
25362536
:error

Diff for: lib/elixir/test/elixir/exception_test.exs

+10
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ defmodule ExceptionTest do
4646
{:io, :put_chars, [self(), <<222>>],
4747
[error_info: %{module: __MODULE__, function: :dummy_error_extras}]}
4848
])
49+
50+
assert %ErlangError{original: {:failed_load_cacerts, :enoent}, reason: ": this is chardata"} =
51+
Exception.normalize(:error, {:failed_load_cacerts, :enoent}, [
52+
{:pubkey_os_cacerts, :get, 0,
53+
[error_info: %{module: __MODULE__, function: :dummy_error_chardata}]}
54+
])
4955
end
5056

5157
test "format/2 without stacktrace" do
@@ -1026,4 +1032,8 @@ defmodule ExceptionTest do
10261032
end
10271033

10281034
def dummy_error_extras(_exception, _stacktrace), do: %{general: "foo"}
1035+
1036+
def dummy_error_chardata(_exception, _stacktrace) do
1037+
%{general: ~c"this is " ++ [~c"chardata"], reason: ~c"this " ++ [~c"too"]}
1038+
end
10291039
end

0 commit comments

Comments
 (0)