Skip to content

Commit 555eac7

Browse files
committed
Do not treat streaming errors as file errors, closes #13323
1 parent 9973a2e commit 555eac7

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

lib/elixir/lib/io/stream.ex

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
defmodule IO.StreamError do
2-
defexception [:reason, :message]
2+
defexception [:reason]
33

44
@impl true
5-
def exception(opts) do
6-
reason = opts[:reason]
7-
formatted = IO.iodata_to_binary(:file.format_error(reason))
8-
%IO.StreamError{message: "error during streaming: #{formatted}", reason: reason}
5+
def message(%{reason: reason}) do
6+
"error during streaming: #{inspect(reason)}"
97
end
108
end
119

lib/elixir/test/elixir/string_io_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ defmodule StringIOTest do
267267
test "IO.stream with invalid UTF-8" do
268268
{:ok, pid} = StringIO.open(<<130, 227, 129, 132, 227, 129, 134>>)
269269

270-
assert_raise IO.StreamError, fn ->
270+
assert_raise IO.StreamError, "error during streaming: :invalid_unicode", fn ->
271271
IO.stream(pid, 2) |> Enum.to_list()
272272
end
273273

0 commit comments

Comments
 (0)