3#ifndef LIGHTLY_EDGE_ERROR_H
4#define LIGHTLY_EDGE_ERROR_H
6#include "tl/expected.hpp"
49 explicit Exception(std::string message) : message_(std::move(message)) {}
50 [[nodiscard]]
auto what()
const noexcept ->
const char *
override {
51 return message_.c_str();
79inline auto value_or_throw(tl::expected<T, lightly_edge_sdk::Error> &&result) -> T {
80 if (!result.has_value()) {
81 throw Exception(std::move(result).error().message);
83 return std::move(*result);
88inline void value_or_throw(tl::expected<void, lightly_edge_sdk::Error> &&result) {
89 if (!result.has_value()) {
90 throw Exception(std::move(result).error().message);
Exception class for lightly_edge_sdk::value_or_throw function.
Definition lightly_edge_error.h:44
Namespace with core LightlyEdge SDK functionality.
Definition lightly_edge_error.h:15
auto value_or_throw(tl::expected< T, lightly_edge_sdk::Error > &&result) -> T
Convenience function to unwrap a result of lightly_edge_sdk::LightlyEdge functions.
Definition lightly_edge_error.h:79
Error struct to hold error code and message.
Definition lightly_edge_error.h:20
std::string message
Error message.
Definition lightly_edge_error.h:33
uint16_t code
Error code.
Definition lightly_edge_error.h:26