File.Error exception (Elixir v1.19.0-dev)

View Source

An exception that is raised when a file operation fails.

For example, this exception is raised, when trying to read a non existent file:

iex> File.read!("nonexistent_file.txt")
** (File.Error) could not read file "nonexistent_file.txt": no such file or directory

The following fields of this exception are public and can be accessed freely:

  • :path (Path.t/0) - the path of the file that caused the error
  • :reason (File.posix/0) - the reason for the error