HH\Lib\OS\ErrnoException
Base class for exceptions reported via the C errno variable
Subclasses exist for some specific Errno values, such as:
ChildProcessException(ECHILD)ConnectionExceptionand its' subclasses,BrokenPipeException(EPIPE,ESHUTDOWN),ConnectionAbortedException(ECONNABORTED),ConnectionRefusedException(ECONNREFUSED), andConnectionResetException(ECONNRESET)AlreadyExistsException(EEXIST)NotFoundException(ENOENT)IsADirectoryException(EISDIR)IsNotADirectoryException(ENOTDIR)PermissionException(EACCESS,EPERM)ProcessLookupException(ESRCH)TimeoutError(ETIMEDOUT)
It is strongly recommended to catch subclasses instead of this class if a suitable subclass is defined; for example:
// ANTIPATTERN:
catch (OS\ErrnoException $e) {
if ($e->getErrno() === OS\Errno::ENOENT) {
do_stuff();
}
}
// RECOMMENDED:
catch (OS\NotFoundException $_) {
do_stuff();
}
If a suitable subclass is not defined, the antipattern is unavoidable.
Interface Synopsis
namespace HH\Lib\OS;
class ErrnoException extends \Exception {...}
Public Methods
->__construct(Errno $errno, string $message)->getCode(): Errno
Deprecated for clarity, and potential future ambiguity->getErrno(): Errno