139 class Error final :
public std::runtime_error {
160 : std::runtime_error(std::move(msg)), lvl(l), errType(err), retries(t) {}
187 bool isFatal() const noexcept {
return lvl == Level::Fatal; }
193 bool isWarning() const noexcept {
return lvl == Level::Warning; }
196 bool isError() const noexcept {
return lvl == Level::Error; }
202 explicit operator bool() const noexcept {
return lvl != Level::None; }
223 static Error fromLastWinError(DWORD error, std::string_view context =
"", std::optional<unsigned int> tries = std::nullopt);
234 static Error fromLastWinError(std::string_view context =
"", std::optional<unsigned int> tries = std::nullopt);
251 unsigned int retries;
263 template <
typename T>
264 using Result = std::expected<T, DeskUp::Error>;
273 using Status = std::expected<void, DeskUp::Error>;
Defines basic tools to easen the interaction with the Desk Up backend.
Centralized representation of a DeskUp runtime error.
Definition desk_up_error.h:139
bool isError() const noexcept
Whether the error is a system error.
Definition desk_up_error.h:196
bool isRetryable() const noexcept
Whether the error can be retried.
Definition desk_up_error.h:199
bool isWarning() const noexcept
Whether the error is a warning.
Definition desk_up_error.h:193
int attempts() const noexcept
Returns how many times the operation was retried.
Definition desk_up_error.h:178
bool isFatal() const noexcept
Whether the error is fatal.
Definition desk_up_error.h:187
Error(Level l, ErrType err, unsigned int t, std::string msg)
Constructs an error with full metadata.
Definition desk_up_error.h:159
windowDesc whichWindow() const noexcept
Returns the affected window (if available).
Definition desk_up_error.h:184
Error()
Default constructor (represents a non-error).
Definition desk_up_error.h:147
static Error fromSaveError(int e)
Converts a SaveErrorCode (from window_desc.cc) into a structured error.
Definition desk_up_error.cc:88
bool isSkippable() const noexcept
Whether the error is skipable.
Definition desk_up_error.h:190
ErrType type() const noexcept
Returns the error type.
Definition desk_up_error.h:166
Level level() const noexcept
Returns the error severity level.
Definition desk_up_error.h:172
ErrType
Represents the underlying type or origin of an error.
Definition desk_up_error.h:89
@ CorruptedData
Data corruption detected.
Definition desk_up_error.h:102
@ SharingViolation
Another process holds an exclusive lock.
Definition desk_up_error.h:92
@ FileNotFound
File could not be located.
Definition desk_up_error.h:99
@ FunctionFailed
Generic function fail.
Definition desk_up_error.h:111
@ OutOfRange
Index or parameter out of valid range.
Definition desk_up_error.h:103
@ NotFound
Resource not found.
Definition desk_up_error.h:94
@ Io
Generic input/output error.
Definition desk_up_error.h:93
@ NetworkError
Generic network failure.
Definition desk_up_error.h:104
@ DiskFull
Storage volume full.
Definition desk_up_error.h:95
@ HostUnreachable
Target host cannot be reached.
Definition desk_up_error.h:106
@ ResourceBusy
Resource is in use.
Definition desk_up_error.h:98
@ NotImplemented
Feature not yet implemented.
Definition desk_up_error.h:109
@ ConnectionRefused
Connection attempt refused.
Definition desk_up_error.h:105
@ PolicyUpdated
External factors like dll dependencies have changed.
Definition desk_up_error.h:110
@ Unexpected
Unexpected runtime condition.
Definition desk_up_error.h:108
@ Timeout
Operation timed out.
Definition desk_up_error.h:97
@ ProtocolError
Violation of expected protocol behavior.
Definition desk_up_error.h:107
@ DeviceNotFound
Device unavailable or disconnected.
Definition desk_up_error.h:96
@ AccessDenied
Permission denied by the OS or file system.
Definition desk_up_error.h:91
@ InvalidInput
Invalid parameter passed by the caller.
Definition desk_up_error.h:101
@ InvalidFormat
Invalid file or data format.
Definition desk_up_error.h:100
@ InsufficientMemory
Memory allocation failed or system out of resources.
Definition desk_up_error.h:90
Level
Represents the severity of an error.
Definition desk_up_error.h:65
std::expected< T, DeskUp::Error > Result
Alias for an operation result that either holds a value or a DeskUp error.
Definition desk_up_error.h:264
std::expected< void, DeskUp::Error > Status
Alias for an operation that returns success or failure (void on success).
Definition desk_up_error.h:273
Describes a single window instance in the DeskUp system.
Definition window_desc.h:60
Defines the abstract data structure used to represent a window in DeskUp.