FastLED 3.9.15
Loading...
Searching...
No Matches
error_code.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/task/promise.h"
4#include "fl/stl/stdint.h"
5#include "fl/stl/string.h"
6#include "fl/stl/noexcept.h"
7
8namespace fl {
9namespace asio {
10
25
31struct error_code {
33 fl::string message; // optional human-readable detail
34
36 error_code(errc c) : code(c) {}
37 error_code(errc c, const fl::string &msg) : code(c), message(msg) {}
38 error_code(errc c, const char *msg) : code(c), message(msg) {}
39
41 explicit operator bool() const { return code != errc::success; }
42
44 bool ok() const { return code == errc::success; }
45
48 if (e.is_empty()) {
49 return error_code();
50 }
52 }
53
56 if (ok()) {
57 return fl::task::Error();
58 }
60 }
61
63 static error_code from_errno(int platform_errno);
64
65 bool operator==(const error_code &o) const { return code == o.code; }
66 bool operator!=(const error_code &o) const { return code != o.code; }
67};
68
69} // namespace asio
70} // namespace fl
errc
Asio-compatible error code enumeration.
Definition error_code.h:13
Base definition for an LED controller.
Definition crgb.hpp:179
Promise-based fluent API for FastLED - standalone async primitives.
#define FL_NOEXCEPT
error_code(errc c, const fl::string &msg)
Definition error_code.h:37
bool operator==(const error_code &o) const
Definition error_code.h:65
fl::task::Error to_error() const
Convert to fl::task::Error for interop with existing FastLED code.
Definition error_code.h:55
error_code() FL_NOEXCEPT
Definition error_code.h:35
static error_code from_errno(int platform_errno)
Convert from platform errno value.
bool ok() const
Convenience: true if no error.
Definition error_code.h:44
static error_code from_error(const fl::task::Error &e)
Convert from fl::task::Error for interop with existing FastLED code.
Definition error_code.h:47
error_code(errc c, const char *msg)
Definition error_code.h:38
bool operator!=(const error_code &o) const
Definition error_code.h:66
Asio-compatible error code: numeric code + optional human-readable message.
Definition error_code.h:31
bool is_empty() const FL_NOEXCEPT
Definition promise.h:46
fl::string message
Definition promise.h:40
Error type for promises.
Definition promise.h:39