libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
Error Class Reference

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 Stringname () const
 Returns the human-readable name of the error code.
 
const Stringdesc () const
 Returns a human-readable description of the error.
 
const StringsystemErrorName () 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.
 

Detailed Description

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

Example
// Functions use Error* for fallible results:
auto val = someFunction(&err);
if(err.isError()) {
String msg = err.description();
}
// Direct comparison
if(err == Error::NotExist) { ... }
Lightweight error code wrapper for the promeki library.
Definition error.h:39
@ NotExist
File or resource does not exist (ENOENT).
Definition error.h:71
Dynamic array container wrapping std::vector.
Definition list.h:40
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
a mapping to the corresponding POSIX errno value when applicable.

Member Enumeration Documentation

◆ Code

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.

Constructor & Destructor Documentation

◆ Error()

Error::Error ( Code  code = Ok)
inline

Constructs an Error with the given code.

Parameters
codeThe error code (default: Ok).

Member Function Documentation

◆ code()

Code Error::code ( ) const
inline

Returns the error code.

Returns
The Code enumeration value.

◆ desc()

const String & Error::desc ( ) const

Returns a human-readable description of the error.

Returns
A descriptive String for the error code.

◆ isError()

bool Error::isError ( ) const
inline

Returns true if the error code indicates an error.

Returns
True when the code is non-zero.

◆ isOk()

bool Error::isOk ( ) const
inline

Returns true if the error code is Ok (no error).

Returns
True when the code is zero.

◆ name()

const String & Error::name ( ) const

Returns the human-readable name of the error code.

Returns
A String such as "Ok", "Invalid", "IOError", etc.

◆ syserr() [1/3]

static Error Error::syserr ( )
static

Creates an Error from the last system error.

On POSIX, reads errno. On Windows, reads GetLastError().

Returns
An Error whose code maps to the system error.

◆ syserr() [2/3]

static Error Error::syserr ( const std::error_code &  ec)
static

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.

Parameters
ecThe std::error_code to translate.
Returns
An Error whose code maps to the given error_code.

◆ syserr() [3/3]

static Error Error::syserr ( int  errnum)
static

Creates an Error from an explicit POSIX errno value.

Parameters
errnumThe errno value to translate.
Returns
An Error whose code maps to the given errno.

◆ systemError()

int Error::systemError ( ) const

Returns the POSIX errno value that maps to this error code.

Returns
The errno value, or 0 if there is no mapping.

◆ systemErrorName()

const String & Error::systemErrorName ( ) const

Returns the name of the corresponding POSIX errno symbol.

Returns
A String such as "EINVAL", or an empty string if unmapped.

The documentation for this class was generated from the following file: