Lightweight error code wrapper for the promeki library. More...
#include <error.h>
Public Types | |
| enum | Code { Ok = 0 , UnsupportedSystemError , LibraryFailure , SingularMatrix , NotImplemented , PixelFormatNotSupported , OutOfRange , PermissionDenied , TryAgain , BadFileDesc , Busy , Exists , BadAddress , TooLarge , Interrupt , Invalid , IOError , IsDir , TooManyOpenFiles , TooManyOpenSysFiles , NotExist , NoMem , NoSpace , NotDir , NoPermission , ReadOnly , IllegalSeek , Timeout , CrossDeviceLink , NoFrameRate , AlreadyOpen , NotSupported , OpenFailed , NotOpen , EndOfFile , InvalidArgument , InvalidDimension , NotHostAccessible , BufferTooSmall } |
| Error codes for the promeki library. More... | |
Public Member Functions | |
| Error (Code code=Ok) | |
| Constructs an Error with the given code. | |
| ~Error () | |
| Destructor. | |
| bool | operator== (const Error &other) const |
| Returns true if both errors have the same code. | |
| bool | operator!= (const Error &other) const |
| Returns true if the errors have different codes. | |
| bool | operator< (const Error &other) const |
| Less-than comparison by error code. | |
| bool | operator<= (const Error &other) const |
| Less-than-or-equal comparison by error code. | |
| bool | operator> (const Error &other) const |
| Greater-than comparison by error code. | |
| bool | operator>= (const Error &other) const |
| Greater-than-or-equal comparison by error code. | |
| Code | code () const |
| Returns the error code. | |
| bool | isOk () const |
| Returns true if the error code is Ok (no error). | |
| bool | isError () const |
| Returns true if the error code indicates an error. | |
| const String & | name () const |
| Returns the human-readable name of the error code. | |
| const String & | desc () const |
| Returns a human-readable description of the error. | |
| const String & | systemErrorName () const |
| Returns the name of the corresponding POSIX errno symbol. | |
| int | systemError () const |
| Returns the POSIX errno value that maps to this error code. | |
Static Public Member Functions | |
| static Error | syserr () |
| Creates an Error from the last system error. | |
| static Error | syserr (int errnum) |
| Creates an Error from an explicit POSIX errno value. | |
| static Error | syserr (const std::error_code &ec) |
| Creates an Error from a std::error_code. | |
Lightweight error code wrapper for the promeki library.
Encapsulates an error code from the Code enumeration and provides comparison operators, human-readable names, descriptions, and
Error codes for the promeki library.
New codes should be added here whenever an existing code would be an imprecise fit. Prefer specific, descriptive codes over reusing generic ones. Codes that map to POSIX errno values are noted in error.cpp; domain-specific codes have no errno mapping.
| Enumerator | |
|---|---|
| Ok | No error. |
| UnsupportedSystemError | Unmapped system error. |
| LibraryFailure | An external library call failed. |
| SingularMatrix | Matrix is singular and cannot be inverted. |
| NotImplemented | Feature is not implemented. |
| PixelFormatNotSupported | Pixel format is not supported. |
| OutOfRange | Value is out of range. |
| PermissionDenied | Permission denied (EACCES). |
| TryAgain | Resource temporarily unavailable (EAGAIN). |
| BadFileDesc | Bad file descriptor (EBADF). |
| Busy | Resource is busy (EBUSY). |
| Exists | File or resource already exists (EEXIST). |
| BadAddress | Bad memory address (EFAULT). |
| TooLarge | File too large (EFBIG). |
| Interrupt | Interrupted system call (EINTR). |
| Invalid | Invalid value or argument (EINVAL). |
| IOError | Input/output error (EIO). |
| IsDir | Is a directory (EISDIR). |
| TooManyOpenFiles | Too many open files in process (EMFILE). |
| TooManyOpenSysFiles | Too many open files system-wide (ENFILE). |
| NotExist | File or resource does not exist (ENOENT). |
| NoMem | Out of memory (ENOMEM). |
| NoSpace | No space left on device (ENOSPC). |
| NotDir | Not a directory (ENOTDIR). |
| NoPermission | Operation not permitted (EPERM). |
| ReadOnly | Read-only file system (EROFS). |
| IllegalSeek | Illegal seek (ESPIPE). |
| Timeout | Operation timed out. |
| CrossDeviceLink | Cross-device link (EXDEV). |
| NoFrameRate | No frame rate has been set. |
| AlreadyOpen | Resource is already open. |
| NotSupported | Operation is not supported. |
| OpenFailed | Failed to open a resource. |
| NotOpen | Resource is not open. |
| EndOfFile | End of file reached. |
| InvalidArgument | Invalid argument supplied. |
| InvalidDimension | Invalid dimension value. |
| NotHostAccessible | Memory is not host-accessible. |
| BufferTooSmall | Buffer is too small for the operation. |
Constructs an Error with the given code.
| code | The error code (default: Ok). |
|
inline |
Returns the error code.
Returns a human-readable description of the error.
|
inline |
Returns true if the error code indicates an error.
|
inline |
Returns true if the error code is Ok (no error).
Returns the human-readable name of the error code.
Creates an Error from a std::error_code.
Handles both POSIX (generic_category / system_category on POSIX) and Windows (system_category on Windows) error codes correctly. Returns Ok when the error_code has no error.
| ec | The std::error_code to translate. |
| int Error::systemError | ( | ) | const |
Returns the POSIX errno value that maps to this error code.
Returns the name of the corresponding POSIX errno symbol.