CuteHMI - CuteHMI (CuteHMI.2)
cutehmi::Error Struct Reference

Standarized error. More...

#include <cutehmi/Error.hpp>

Inheritance diagram for cutehmi::Error:
cutehmi::InplaceError

Public Types

enum  : int { UNINITIALIZED = -2, FAIL = -1, OK = 0, SUBCLASS_BEGIN = 1 }
 

Public Member Functions

 Error ()
 Default constructor. More...
 
 Error (int code)
 Conversion constructor. More...
 
bool operator== (const Error &other) const
 
bool operator!= (const Error &other) const
 
 operator bool () const
 Conversion to bool. More...
 
int code () const
 Get error code. More...
 
QString str () const
 Get error string. More...
 

Protected Member Functions

void setCode (int code)
 

Detailed Description

Standarized error.

Class reserves negative values for its error codes. When subclassing start custom error codes from 1 (Error::SUBCLASS_BEGIN).

Member Enumeration Documentation

◆ anonymous enum

anonymous enum : int
Enumerator
UNINITIALIZED 
FAIL 
OK 
SUBCLASS_BEGIN 

Constructor & Destructor Documentation

◆ Error() [1/2]

cutehmi::Error::Error ( )

Default constructor.

◆ Error() [2/2]

cutehmi::Error::Error ( int  code)

Conversion constructor.

Parameters
codeerror code.

Member Function Documentation

◆ code()

int cutehmi::Error::code ( ) const

Get error code.

Returns
error code.

◆ operator bool()

cutehmi::Error::operator bool ( ) const

Conversion to bool.

Evaluates to true if error code is Error::OK, false otherwise.

◆ operator!=()

bool cutehmi::Error::operator!= ( const Error other) const

◆ operator==()

bool cutehmi::Error::operator== ( const Error other) const

◆ setCode()

void cutehmi::Error::setCode ( int  code)
protected

◆ str()

QString cutehmi::Error::str ( ) const

Get error string.

A subclass may reimplement this method to provide its own error descriptions.

Returns
error message.
Note
This function is non-virtual. When calling this function on down-casted instance of derived class, it may not recognize error code and return generic message.