Skip to content

Commit f115784

Browse files
author
Yves Orton
committed
File.LinkError - fix confusing wording
The api for links is ln(existing, new) but the old error text said "from existing to new", where I believe it should have said "to existing from new". The language for this has always been a bit confusing IMO, dating back to the original unix manpages for hard and symbolic links: the order of the arguments is because of the defaulting rules for the command line tool, but in a language context without the defaulting arguably it would be more logical (but against tradition) to reverse the arguments, but that boat has long ago sailed. However we can at least make the error message more intuitive. This patch changes the text to try to make it more clear which is the new link and which is the thing being linked to. Likely this error came from the example using "source.txt" and "target.txt" and it being natural to say "to target", when really in the function call "target.txt" is the link being created and "source.txt" is the thing being linked to. This changes the example to use "existing.txt" and "link.txt" so it is more obvious which is the link and which is the existing file, and uses the word "to" in reference the to the thing being linked to, and "from" in reference to link being created.
1 parent ea2ae22 commit f115784

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/elixir/lib/exception.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2492,8 +2492,8 @@ defmodule File.LinkError do
24922492
24932493
For example, this exception is raised when trying to link to file that isn't present:
24942494
2495-
iex> File.ln!("source.txt", "target.txt")
2496-
** (File.LinkError) could not create hard link from "source.txt" to "target.txt": no such file or directory
2495+
iex> File.ln!("existing.txt", "link.txt")
2496+
** (File.LinkError) could not create hard link to "existing.txt" from "link.txt": no such file or directory
24972497
24982498
The following fields of this exception are public and can be accessed freely:
24992499
@@ -2509,7 +2509,7 @@ defmodule File.LinkError do
25092509
def message(exception) do
25102510
formatted = IO.iodata_to_binary(:file.format_error(exception.reason))
25112511

2512-
"could not #{exception.action} from #{inspect(exception.existing)} to " <>
2512+
"could not #{exception.action} to #{inspect(exception.existing)} from " <>
25132513
"#{inspect(exception.new)}: #{formatted}"
25142514
end
25152515
end

0 commit comments

Comments
 (0)