libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
error.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <system_error>
13
15
16class String;
17
39class Error {
40 public:
91
98 static Error syserr();
99
105 static Error syserr(int errnum);
106
107#if defined(PROMEKI_PLATFORM_WINDOWS)
113 static Error syserr(DWORD winErr);
114#endif
115
126 static Error syserr(const std::error_code &ec);
127
132 Error(Code code = Ok) : _code(code) { }
133
135 ~Error() { }
136
138 bool operator==(const Error &other) const { return _code == other._code; }
140 bool operator!=(const Error &other) const { return _code != other._code; }
142 bool operator<(const Error &other) const { return _code < other._code; }
144 bool operator<=(const Error &other) const { return _code <= other._code; }
146 bool operator>(const Error &other) const { return _code > other._code; }
148 bool operator>=(const Error &other) const { return _code >= other._code; }
149
154 Code code() const { return _code; }
155
160 bool isOk() const { return _code == 0; }
161
166 bool isError() const { return _code != 0; }
167
172 const String &name() const;
173
178 const String &desc() const;
179
184 const String &systemErrorName() const;
185
190 int systemError() const;
191
192 private:
193 Code _code;
194};
195
197
Lightweight error code wrapper for the promeki library.
Definition error.h:39
static Error syserr()
Creates an Error from the last system error.
const String & systemErrorName() const
Returns the name of the corresponding POSIX errno symbol.
~Error()
Destructor.
Definition error.h:135
bool operator<(const Error &other) const
Less-than comparison by error code.
Definition error.h:142
bool operator==(const Error &other) const
Returns true if both errors have the same code.
Definition error.h:138
bool operator>=(const Error &other) const
Greater-than-or-equal comparison by error code.
Definition error.h:148
const String & desc() const
Returns a human-readable description of the error.
bool operator>(const Error &other) const
Greater-than comparison by error code.
Definition error.h:146
bool isError() const
Returns true if the error code indicates an error.
Definition error.h:166
bool operator!=(const Error &other) const
Returns true if the errors have different codes.
Definition error.h:140
Code code() const
Returns the error code.
Definition error.h:154
static Error syserr(int errnum)
Creates an Error from an explicit POSIX errno value.
bool operator<=(const Error &other) const
Less-than-or-equal comparison by error code.
Definition error.h:144
int systemError() const
Returns the POSIX errno value that maps to this error code.
Error(Code code=Ok)
Constructs an Error with the given code.
Definition error.h:132
static Error syserr(const std::error_code &ec)
Creates an Error from a std::error_code.
Code
Error codes for the promeki library.
Definition error.h:50
@ BadAddress
Bad memory address (EFAULT).
Definition error.h:63
@ PixelFormatNotSupported
Pixel format is not supported.
Definition error.h:56
@ TooManyOpenSysFiles
Too many open files system-wide (ENFILE).
Definition error.h:70
@ UnsupportedSystemError
Unmapped system error.
Definition error.h:52
@ NoFrameRate
No frame rate has been set.
Definition error.h:80
@ AlreadyOpen
Resource is already open.
Definition error.h:81
@ NotOpen
Resource is not open.
Definition error.h:84
@ Timeout
Operation timed out.
Definition error.h:78
@ NotSupported
Operation is not supported.
Definition error.h:82
@ Ok
No error.
Definition error.h:51
@ EndOfFile
End of file reached.
Definition error.h:85
@ Exists
File or resource already exists (EEXIST).
Definition error.h:62
@ NoSpace
No space left on device (ENOSPC).
Definition error.h:73
@ OutOfRange
Value is out of range.
Definition error.h:57
@ BufferTooSmall
Buffer is too small for the operation.
Definition error.h:89
@ IOError
Input/output error (EIO).
Definition error.h:67
@ NotImplemented
Feature is not implemented.
Definition error.h:55
@ NoMem
Out of memory (ENOMEM).
Definition error.h:72
@ OpenFailed
Failed to open a resource.
Definition error.h:83
@ NotHostAccessible
Memory is not host-accessible.
Definition error.h:88
@ CrossDeviceLink
Cross-device link (EXDEV).
Definition error.h:79
@ BadFileDesc
Bad file descriptor (EBADF).
Definition error.h:60
@ InvalidDimension
Invalid dimension value.
Definition error.h:87
@ Interrupt
Interrupted system call (EINTR).
Definition error.h:65
@ TooManyOpenFiles
Too many open files in process (EMFILE).
Definition error.h:69
@ Busy
Resource is busy (EBUSY).
Definition error.h:61
@ TryAgain
Resource temporarily unavailable (EAGAIN).
Definition error.h:59
@ InvalidArgument
Invalid argument supplied.
Definition error.h:86
@ NotExist
File or resource does not exist (ENOENT).
Definition error.h:71
@ Invalid
Invalid value or argument (EINVAL).
Definition error.h:66
@ IllegalSeek
Illegal seek (ESPIPE).
Definition error.h:77
@ ReadOnly
Read-only file system (EROFS).
Definition error.h:76
@ NoPermission
Operation not permitted (EPERM).
Definition error.h:75
@ SingularMatrix
Matrix is singular and cannot be inverted.
Definition error.h:54
@ LibraryFailure
An external library call failed.
Definition error.h:53
@ PermissionDenied
Permission denied (EACCES).
Definition error.h:58
@ IsDir
Is a directory (EISDIR).
Definition error.h:68
@ TooLarge
File too large (EFBIG).
Definition error.h:64
@ NotDir
Not a directory (ENOTDIR).
Definition error.h:74
bool isOk() const
Returns true if the error code is Ok (no error).
Definition error.h:160
const String & name() const
Returns the human-readable name of the error code.
Dynamic array container wrapping std::vector.
Definition list.h:40
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19