Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/elixir/lib/exception.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions lib/elixir/test/elixir/exception_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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}]}
])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this will depend on the Erlang/OTP version, I wonder if we should write our own Erlang error that reproduces the failure?

Copy link
Contributor Author

@sabiwara sabiwara Mar 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woops right, there was an example just above reused the same approach: 39ea53e

end

test "format/2 without stacktrace" do
Expand Down Expand Up @@ -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
Loading