# `File.Error`
[🔗](https://github.com/elixir-lang/elixir/blob/v1.20.0-rc.3/lib/elixir/lib/exception.ex#L2375)

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` (`t:Path.t/0`) - the path of the file that caused the error
  * `:reason` (`t:File.posix/0`) - the reason for the error

---

*Consult [api-reference.md](api-reference.md) for complete listing*
