MaxMatrix
Drive chained 8x8 LED dot matrix modules with MAX7219.
Loading...
Searching...
No Matches
max_matrix::Status Class Reference

What a function that can fail returns when it has no value to return. More...

#include <MaxMatrixError.h>

Public Member Functions

 Status (Error error=Error::kOk)
 Makes a status of error, ok when none is given.
MAXMATRIX_NODISCARD Error GetError () const
 Returns why the call failed, or Error::kOk.
MAXMATRIX_NODISCARD __FlashStringHelper const * GetErrorText () const
 Returns the error in a few words, in flash, for Serial.print().
MAXMATRIX_NODISCARD bool IsOk () const
 Returns whether the call did what it was asked.

Friends

bool operator== (Status status, Error error)
 Returns whether the call failed for this reason.
bool operator!= (Status status, Error error)
 Returns whether the call did not fail for this reason.

Detailed Description

What a function that can fail returns when it has no value to return.

A sketch asks IsOk(), or compares with an error:

if(matrix.SetText(text) == max_matrix::Error::kUnknownChar) { ... }
@ kUnknownChar
Definition MaxMatrixError.h:49
Note
It has no conversion to bool, on purpose: with stdReturnType, E_OK was 0, so if(matrix.SetText(...)) was true on an error.

Constructor & Destructor Documentation

◆ Status()

max_matrix::Status::Status ( Error error = Error::kOk)
inline

Makes a status of error, ok when none is given.

Implicit, so that a function returns an error as it is.

Parameters
[in]errorThe error, or Error::kOk.

Member Function Documentation

◆ GetErrorText()

MAXMATRIX_NODISCARD __FlashStringHelper const * max_matrix::Status::GetErrorText ( ) const

Returns the error in a few words, in flash, for Serial.print().

"out of range" for Error::kOutOfRange. Serial.print() reads a __FlashStringHelper from flash, so the text needs no RAM. A sketch that never calls it pays nothing, as the linker drops it with its texts.

Returns
The text; "unknown error" for a byte cast to the enum that is none of its values.

◆ operator!=

bool operator!= ( Status status,
Error error )
friend

Returns whether the call did not fail for this reason.

Parameters
[in]statusThe status of the call.
[in]errorThe error to compare with.

◆ operator==

bool operator== ( Status status,
Error error )
friend

Returns whether the call failed for this reason.

Parameters
[in]statusThe status of the call.
[in]errorThe error to compare with.

The documentation for this class was generated from the following file: