HH\Lib\Experimental\OS\Exception

Base class for exceptions reported by primitive native operations

This is used for errors that are indicated by errno, herror, or similar interfaces covered by the ErrorCode enum.

Subclasses exist for some specific ErrorCode values, such as:

It is strongly recommended to catch subclasses instead of this class if a suitable subclass is defined; for example:

// ANTIPATTERN:
catch (OS\Exception $e) {
  if ($e->getErrorCode() === OS\ErrorCode::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\Experimental\OS;

class Exception extends \Exception {...}

Public Methods