esp-vfd-clock/firmware/main/esp_expected.hpp
2024-01-16 16:39:30 +02:00

24 lines
403 B
C++

//
// Created by erki on 16/01/24.
//
#pragma once
#include <expected>
#include <esp_err.h>
#define TRY(x) ({ \
const auto& _x = (x); \
if (!_x) { \
return std::unexpected(_x.error()); \
} \
_x.value(); \
})
#define TRY_ESP(x) ({ \
const esp_err_t& _x = (x); \
if (_x != ESP_OK) \
return std::unexpected(_x); \
_x; \
})