package posix-errno
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=464f431a8517dba4295286dd61f3ff2c
sha512=36d4c64987848fc06a4296c2141d250d95db0092b2d9d4d95f301f5eaada9a3df8ae9703fc8f2407596f6fb474a69863abd5e3d2c08636eb2c0dd67477d316e8
doc/posix-errno/Posix_errno/index.html
Module Posix_errnoSource
POSIX errno handling
Errno Type
type t = [ | `E2BIG| `EACCES| `EADDRINUSE| `EADDRNOTAVAIL| `EAFNOSUPPORT| `EAGAIN| `EALREADY| `EBADF| `EBADMSG| `EBUSY| `ECANCELED| `ECHILD| `ECONNABORTED| `ECONNREFUSED| `ECONNRESET| `EDEADLK| `EDESTADDRREQ| `EDOM| `EDQUOT| `EEXIST| `EFAULT| `EFBIG| `EHOSTDOWN| `EHOSTUNREACH| `EIDRM| `EILSEQ| `EINPROGRESS| `EINTR| `EINVAL| `EIO| `EISCONN| `EISDIR| `ELOOP| `EMFILE| `EMLINK| `EMSGSIZE| `EMULTIHOP| `ENAMETOOLONG| `ENETDOWN| `ENETRESET| `ENETUNREACH| `ENFILE| `ENOBUFS| `ENODATA| `ENODEV| `ENOENT| `ENOEXEC| `ENOLCK| `ENOLINK| `ENOMEM| `ENOMSG| `ENOPROTOOPT| `ENOSPC| `ENOSR| `ENOSTR| `ENOSYS| `ENOTCONN| `ENOTDIR| `ENOTEMPTY| `ENOTRECOVERABLE| `ENOTSOCK| `ENOTSUP| `ENOTTY| `ENXIO| `EOPNOTSUPP| `EOVERFLOW| `EOWNERDEAD| `EPERM| `EPFNOSUPPORT| `EPIPE| `EPROTO| `EPROTONOSUPPORT| `EPROTOTYPE| `ERANGE| `EREMOTE| `EROFS| `ESHUTDOWN| `ESOCKTNOSUPPORT| `ESPIPE| `ESRCH| `ESTALE| `ETIME| `ETIMEDOUT| `ETOOMANYREFS| `ETXTBSY| `EUSERS| `EWOULDBLOCK| `EXDEV| `EBADE| `EBADFD| `EBADR| `EBADRQC| `EBADSLT| `ECHRNG| `ECOMM| `EDEADLOCK| `EHWPOISON| `EISNAM| `EKEYEXPIRED| `EKEYREJECTED| `EKEYREVOKED| `EL2HLT| `EL2NSYNC| `EL3HLT| `EL3RST| `ELIBACC| `ELIBBAD| `ELIBEXEC| `ELIBMAX| `ELIBSCN| `ELNRNG| `EMEDIUMTYPE| `ENOANO| `ENOKEY| `ENOMEDIUM| `ENONET| `ENOPKG| `ENOTBLK| `ENOTUNIQ| `EREMCHG| `EREMOTEIO| `ERESTART| `ERFKILL| `ESTRPIPE| `ETOOBIG| `EUCLEAN| `EUNATCH| `EXFULL| `EAUTH| `EBADRPC| `EFTYPE| `ENEEDAUTH| `ENOCSI| `EPROCLIM| `EPROCUNAVAIL| `EPROGMISMATCH| `EPROGUNAVAIL| `ERPCMISMATCH| `EATTR| `EBADARCH| `EBADEXEC| `EBADMACHO| `EDEVERR| `ENOATTR| `ENOPOLICY| `EPWROFF| `ESHLIBVERS| `EOTHER| `EUNKNOWN of int
]Comprehensive errno type covering Linux, BSD, macOS, and Windows values
Errno Conversion
Errno Access
Get current errno as int
Reset errno to 0
Error Raising
Generic error-raising function.
raise_on_error ?call f check calls f() and checks the result with check. If check returns true, raises a Unix_error based on the current errno.
Specialized Error Checkers
Check for negative integer return (common for syscalls). Raises Unix_error if result < 0.
Check for null pointer return (for C functions). Raises Unix_error if result is null.
Check for zero return value (some functions return 0 on error). Raises Unix_error if result = 0.
Check for None return value. Raise Unix_error if result = None.
Unix Error Conversion
Convert errno variant to Unix.error
Convert errno int to Unix.error
Error String Functions
Get error message string for an errno value using strerror. This function is cross-platform (works on both POSIX and Windows) but not thread-safe.
Get error message string for an errno value using strerror_r. This function is thread-safe but only available on POSIX systems.
Native Definition Detection
Check if an errno value is natively defined on this platform. Returns true if the errno is natively defined by the system, false if it's using a placeholder fallback value.
This is useful to determine if an errno constant represents a real system error on the current platform, or if it's just a placeholder value (typically in the 10000+ range) that was assigned because the error doesn't exist on this system.