#pragma once #include #include #include namespace alvin { enum class ErrorCode { Unknown, Unsupported, // backend or feature not available on this platform/session NotAvailable, // backend compiled in but its service/device isn't present PermissionDenied, // e.g. /dev/uinput not writable, portal request denied Cancelled, // user dismissed a portal dialog Timeout, InvalidArgument, NotFound, Io, Protocol, // unexpected reply from a compositor / portal / IPC socket }; struct Error { ErrorCode code = ErrorCode::Unknown; std::string message; }; template using Result = std::expected; using Status = Result; inline std::unexpected fail(ErrorCode code, std::string message) { return std::unexpected(Error{code, std::move(message)}); } std::string_view toString(ErrorCode code) noexcept; } // namespace alvin