Fil.InvalidPathError exception (Fil v0.5.1)

Copy Markdown View Source

The path can't be used here. Use another path.

Fil returns it with reason: :ebadpath for a path that escapes the disk root or contains a control character, before any adapter or plugin sees it, and with reason: :eisdir for the disk root used as a file (a read, a write, a delete, a copy or a move, or a URL), before the adapter sees it. Adapters return it for a file operation on a directory (:eisdir), a path under a file (:enotdir), a name that's too long and a symlink loop, where the storage tells these apart. Fil.Plug answers it with a 404.

iex> disk = Fil.disk(adapter: Fil.Adapter.Memory)
iex> {:error, %Fil.InvalidPathError{} = error} = Fil.read(disk, "../escape.txt")
iex> Exception.message(error)
~s|could not read "../escape.txt" on #Fil.Disk<memory>: invalid path (:ebadpath)|

Summary

Types

t()

@type t() :: %Fil.InvalidPathError{
  __exception__: term(),
  disk: Fil.Disk.t() | nil,
  op: Fil.Op.name() | nil,
  path: String.t() | nil,
  reason: term()
}