REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
Loading...
Searching...
No Matches

A recoverable error, inspired from https://abseil.io/docs/cpp/guides/status and https://github.com/abseil/abseil-cpp/blob/master/absl/status/status.h. More...

#include <error.h>

Collaboration diagram for utils::status:

Public Member Functions

 status (int code, std::string msg)
 
 status ()
 Empty means success. See also success() method for more verbosity in code.
 
 status (int code)
 0 means success, anything else not success.
 
 status (bool code)
 True means success, false not success.
 
 status (std::string msg)
 Generic failure (without code)
 
 status (const char *msg)
 
template<typename... Args>
 status (const char *format, Args... args)
 Usage like status("Foo %d bar %s baz", 3, "bling");.
 
template<typename... Args>
 status (int code, const char *format, Args... args)
 
statusattach (const status &other, const char *description="")
 Attach another error message to this one. Is chainable, returns self.
 
statusattach_to (status &other, const char *description="")
 Attach this error message to another one. Is chainable, returns self.
 
statusattach (int _code, const char *_msg)
 Attach a "raw" message to this one.
 
statusattach (const char *_msg)
 
bool is_ok () const
 
 operator bool () const
 Class instances cast to bool where true means success and false means failure.
 

Static Public Member Functions

static status success ()
 Syntactic sugar for success.
 
static status failure ()
 Syntactic sugar for failure.
 

Public Attributes

int code
 Status code. 0 means success.
 
std::string msg
 Human readable error string.
 

Detailed Description

A recoverable error, inspired from https://abseil.io/docs/cpp/guides/status and https://github.com/abseil/abseil-cpp/blob/master/absl/status/status.h.

This class should be used as immutable.

For making the success path cheap, use status::success.

Definition at line 35 of file error.h.

Constructor & Destructor Documentation

◆ status() [1/8]

utils::status::status ( int code,
std::string msg )
inline

Definition at line 40 of file error.h.

References code, LOG4, and LOG_ALWAYS.

◆ status() [2/8]

utils::status::status ( )
inline

Empty means success. See also success() method for more verbosity in code.

Definition at line 50 of file error.h.

Referenced by failure(), and success().

◆ status() [3/8]

utils::status::status ( int code)
inlineexplicit

0 means success, anything else not success.

Definition at line 53 of file error.h.

◆ status() [4/8]

utils::status::status ( bool code)
inlineexplicit

True means success, false not success.

Definition at line 56 of file error.h.

◆ status() [5/8]

utils::status::status ( std::string msg)
inlineexplicit

Generic failure (without code)

Definition at line 59 of file error.h.

◆ status() [6/8]

utils::status::status ( const char * msg)
inlineexplicit

Definition at line 62 of file error.h.

◆ status() [7/8]

template<typename... Args>
utils::status::status ( const char * format,
Args... args )
inline

Usage like status("Foo %d bar %s baz", 3, "bling");.

Definition at line 66 of file error.h.

◆ status() [8/8]

template<typename... Args>
utils::status::status ( int code,
const char * format,
Args... args )
inline

Definition at line 69 of file error.h.

Member Function Documentation

◆ attach() [1/3]

status & utils::status::attach ( const char * _msg)
inline

Definition at line 93 of file error.h.

◆ attach() [2/3]

status & utils::status::attach ( const status & other,
const char * description = "" )
inline

Attach another error message to this one. Is chainable, returns self.

Definition at line 72 of file error.h.

References code, is_ok(), and msg.

Referenced by attach_to(), blocks::Router::route_carrier(), blocks::Router::route_stack(), platform::LUCIDAC::write_to_hardware(), and platform::LUCIDACFrontPanel::write_to_hardware().

◆ attach() [3/3]

status & utils::status::attach ( int _code,
const char * _msg )
inline

Attach a "raw" message to this one.

Definition at line 87 of file error.h.

References code.

◆ attach_to()

status & utils::status::attach_to ( status & other,
const char * description = "" )
inline

Attach this error message to another one. Is chainable, returns self.

Definition at line 81 of file error.h.

References attach().

Referenced by platform::LUCIDAC::write_to_hardware().

◆ failure()

static status utils::status::failure ( )
inlinestatic

◆ is_ok()

bool utils::status::is_ok ( ) const
inline

Definition at line 98 of file error.h.

References code.

Referenced by attach(), and operator bool().

◆ operator bool()

utils::status::operator bool ( ) const
inline

Class instances cast to bool where true means success and false means failure.

Definition at line 101 of file error.h.

References is_ok().

◆ success()

static status utils::status::success ( )
inlinestatic

Syntactic sugar for success.

Definition at line 104 of file error.h.

References status().

Referenced by blocks::UBlock::_config_constants_from_json(), blocks::CBlock::_config_elements_form_json(), blocks::MIntBlock::_config_elements_from_json(), blocks::MMulBlock::_config_elements_from_json(), platform::LUCIDACFrontPanel::_config_leds_from_json(), blocks::IBlock::_config_outputs_from_json(), blocks::UBlock::_config_outputs_from_json(), platform::LUCIDACFrontPanel::_config_signal_generator_from_json(), blocks::IBlock::_config_upscaling_from_json(), blocks::IBlock::_connect_from_json(), daq::calibrate(), entities::Entity::config_children_from_json(), entities::Entity::config_from_json(), blocks::CBlock::config_self_from_json(), blocks::CTRLBlock::config_self_from_json(), blocks::EmptyMBlock::config_self_from_json(), blocks::IBlock::config_self_from_json(), blocks::MIntBlock::config_self_from_json(), blocks::MMulBlock::config_self_from_json(), blocks::TBlock::config_self_from_json(), blocks::UBlock::config_self_from_json(), carrier::Carrier::config_self_from_json(), platform::Cluster::config_self_from_json(), platform::LUCIDAC::config_self_from_json(), platform::LUCIDACFrontPanel::config_self_from_json(), platform::REDACBackPanel::config_self_from_json(), blocks::TBlock::connect(), daq::init(), daq::stream::process(), blocks::Router::route_carrier(), blocks::Router::route_stack(), daq::stream::start(), daq::stream::stop(), entities::Entity::user_get_config(), carrier::Carrier::user_get_overload_status(), entities::Entity::user_reset_config(), entities::Entity::user_set_config(), carrier::Carrier::user_set_extended_config(), blocks::MIntBlock_V_1_1_X::write_calibration_to_hardware(), blocks::MMulBlock::write_calibration_to_hardware(), blocks::MMulBlock_FullAutoCalibration::write_calibration_to_hardware(), blocks::CBlock::write_to_hardware(), blocks::EmptyMBlock::write_to_hardware(), blocks::MIntBlock::write_to_hardware(), blocks::SHBlock::write_to_hardware(), blocks::TBlock::write_to_hardware(), blocks::UBlock::write_to_hardware(), entities::Entity::write_to_hardware(), platform::Cluster::write_to_hardware(), platform::LUCIDACFrontPanel::SignalGenerator::write_to_hardware(), and platform::REDAC::write_to_hardware().

Member Data Documentation

◆ code

◆ msg


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