24 lines
403 B
C++
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; \
|
|
})
|