Packages

Complete, safe, ergonomic file operations for all Gleam targets

Current section

Files

Jump to
fio src fio@error.erl
Raw

src/fio@error.erl

-module(fio@error).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/fio/error.gleam").
-export([describe/1]).
-export_type([fio_error/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-type fio_error() :: eacces |
eagain |
ebadf |
ebadmsg |
ebusy |
edeadlk |
edquot |
eexist |
efault |
efbig |
eintr |
einval |
eio |
eisdir |
eloop |
emfile |
emlink |
enametoolong |
enfile |
enodev |
enoent |
enomem |
enospc |
enosys |
enotblk |
enotdir |
enotsup |
enxio |
enotempty |
eoverflow |
eperm |
epipe |
erange |
erofs |
espipe |
esrch |
estale |
etxtbsy |
exdev |
{not_utf8, binary()} |
{path_traversal, binary()} |
{outside_base, binary(), binary()} |
{invalid_path, binary(), binary()} |
{atomic_failed, binary(), binary()} |
{temp_failed, binary()} |
{unknown, binary(), gleam@option:option(binary())}.
-file("src/fio/error.gleam", 105).
?DOC(" Convert a FioError to a human-readable description.\n").
-spec describe(fio_error()) -> binary().
describe(Error) ->
case Error of
eacces ->
<<"Permission denied"/utf8>>;
eagain ->
<<"Resource temporarily unavailable"/utf8>>;
ebadf ->
<<"Bad file descriptor"/utf8>>;
ebadmsg ->
<<"Bad message"/utf8>>;
ebusy ->
<<"File busy"/utf8>>;
edeadlk ->
<<"Resource deadlock avoided"/utf8>>;
edquot ->
<<"Disk quota exceeded"/utf8>>;
eexist ->
<<"File already exists"/utf8>>;
efault ->
<<"Bad address in system call argument"/utf8>>;
efbig ->
<<"File too large"/utf8>>;
eintr ->
<<"Interrupted system call"/utf8>>;
einval ->
<<"Invalid argument"/utf8>>;
eio ->
<<"I/O error"/utf8>>;
eisdir ->
<<"Illegal operation on a directory"/utf8>>;
eloop ->
<<"Too many levels of symbolic links"/utf8>>;
emfile ->
<<"Too many open files"/utf8>>;
emlink ->
<<"Too many links"/utf8>>;
enametoolong ->
<<"Filename too long"/utf8>>;
enfile ->
<<"File table overflow"/utf8>>;
enodev ->
<<"No such device"/utf8>>;
enoent ->
<<"No such file or directory"/utf8>>;
enomem ->
<<"Not enough memory"/utf8>>;
enospc ->
<<"No space left on device"/utf8>>;
enosys ->
<<"Function not implemented"/utf8>>;
enotblk ->
<<"Block device required"/utf8>>;
enotdir ->
<<"Not a directory"/utf8>>;
enotsup ->
<<"Operation not supported"/utf8>>;
enxio ->
<<"No such device or address"/utf8>>;
enotempty ->
<<"Directory not empty"/utf8>>;
eoverflow ->
<<"Value too large to be stored in data type"/utf8>>;
eperm ->
<<"Operation not permitted"/utf8>>;
epipe ->
<<"Broken pipe"/utf8>>;
erange ->
<<"Result too large"/utf8>>;
erofs ->
<<"Read-only file system"/utf8>>;
espipe ->
<<"Invalid seek"/utf8>>;
esrch ->
<<"No such process"/utf8>>;
estale ->
<<"Stale remote file handle"/utf8>>;
etxtbsy ->
<<"Text file busy"/utf8>>;
exdev ->
<<"Cross-domain link"/utf8>>;
{not_utf8, Path} ->
<<"File is not valid UTF-8: "/utf8, Path/binary>>;
{path_traversal, Path@1} ->
<<"Path traversal attempt blocked: "/utf8, Path@1/binary>>;
{outside_base, Path@2, Base} ->
<<<<<<"Path "/utf8, Path@2/binary>>/binary,
" is outside base directory "/utf8>>/binary,
Base/binary>>;
{invalid_path, Path@3, Reason} ->
<<<<<<"Invalid path "/utf8, Path@3/binary>>/binary, ": "/utf8>>/binary,
Reason/binary>>;
{atomic_failed, Op, Reason@1} ->
<<<<<<"Atomic "/utf8, Op/binary>>/binary, " failed: "/utf8>>/binary,
Reason@1/binary>>;
{temp_failed, Reason@2} ->
<<"Temp file operation failed: "/utf8, Reason@2/binary>>;
{unknown, Inner, Context} ->
case Context of
none ->
<<"Unknown error: "/utf8, Inner/binary>>;
{some, Ctx} ->
<<<<<<<<"Unknown error: "/utf8, Inner/binary>>/binary,
" ("/utf8>>/binary,
Ctx/binary>>/binary,
")"/utf8>>
end
end.