13#ifndef MAXMATRIX_SRC_MAXMATRIXERROR_H_
14#define MAXMATRIX_SRC_MAXMATRIXERROR_H_
34#if (MAXMATRIX_DEV_ERROR_DETECT == STD_ON)
36#define MAXMATRIX_REPORT_ERROR(Api, Call) \
37 ::max_matrix::internal::ReportIfError(F(Api), Call)
40#define MAXMATRIX_REPORT_ERROR(Api, Call) (Call)
115 return status.error_ == error;
125 return !(status == error);
140template <
typename ValueType>
157 : value_{value}, error_{
Error::
kOk} {}
167 : value_{}, error_{error} {}
190 return result.error_ == error;
200 return !(result == error);
204#if (MAXMATRIX_DEV_ERROR_DETECT == STD_ON)
219void ReportError(__FlashStringHelper
const* api, Error error);
231void PrintError(__FlashStringHelper
const* api, Error error);
238template <
typename ResultType>
239ResultType ReportIfError(__FlashStringHelper
const* api, ResultType result) {
240 if (!result.IsOk()) {
241 ReportError(api, result.GetError());
The attributes of a later standard, as macros, where the compiler has them.
#define MAXMATRIX_NODISCARD
Marks a function whose result must not be dropped: the compiler warns where it is.
Definition MaxMatrixAttributes.h:37
Configuration of the MaxMatrix library.
Error
Why a call did not do what it was asked; one byte, so that it returns in a register.
Definition MaxMatrixError.h:45
@ kUnknownCommand
Definition MaxMatrixError.h:53
@ kUnknownChar
Definition MaxMatrixError.h:49
@ kLineTooLong
Definition MaxMatrixError.h:55
@ kNotANumber
Definition MaxMatrixError.h:52
@ kNoText
Definition MaxMatrixError.h:50
@ kOk
Definition MaxMatrixError.h:46
@ kOutOfRange
Definition MaxMatrixError.h:48
@ kNotAFont
Definition MaxMatrixError.h:58
friend bool operator!=(Result const &result, Error error)
Returns whether there is a value, or none for another reason.
Definition MaxMatrixError.h:199
Result(ValueType value)
Makes a result that holds value.
Definition MaxMatrixError.h:156
Result(Error error)
Makes a result that holds why there is no value.
Definition MaxMatrixError.h:166
MAXMATRIX_NODISCARD __FlashStringHelper const * GetErrorText() const
Returns the error in a few words, in flash, for Serial.print().
Definition MaxMatrixError.h:176
MAXMATRIX_NODISCARD ValueType GetValue() const
Returns the value; 0, or what ValueType() is, after an error.
Definition MaxMatrixError.h:170
MAXMATRIX_NODISCARD bool IsOk() const
Returns whether there is a value.
Definition MaxMatrixError.h:181
friend bool operator==(Result const &result, Error error)
Returns whether there is no value for this reason.
Definition MaxMatrixError.h:189
MAXMATRIX_NODISCARD Error GetError() const
Returns why there is no value, or Error::kOk.
Definition MaxMatrixError.h:173
What a function that can fail returns when it has no value to return.
Definition MaxMatrixError.h:73
Status(Error error=Error::kOk)
Makes a status of error, ok when none is given.
Definition MaxMatrixError.h:87
friend bool operator!=(Status status, Error error)
Returns whether the call did not fail for this reason.
Definition MaxMatrixError.h:124
MAXMATRIX_NODISCARD Error GetError() const
Returns why the call failed, or Error::kOk.
Definition MaxMatrixError.h:91
friend bool operator==(Status status, Error error)
Returns whether the call failed for this reason.
Definition MaxMatrixError.h:114
MAXMATRIX_NODISCARD bool IsOk() const
Returns whether the call did what it was asked.
Definition MaxMatrixError.h:106
MAXMATRIX_NODISCARD __FlashStringHelper const * GetErrorText() const
Returns the error in a few words, in flash, for Serial.print().