paho-mqtt-cpp
MQTT C++ Client for POSIX and Windows
Public Member Functions | Static Public Member Functions | Protected Attributes
mqtt::exception Class Reference

#include <exception.h>

Inheritance diagram for mqtt::exception:
mqtt::missing_response mqtt::persistence_exception mqtt::security_exception mqtt::timeout_error

Public Member Functions

 exception (int rc)
 
 exception (int rc, ReasonCode reasonCode)
 
 exception (int rc, const string &msg)
 
 exception (int rc, ReasonCode reasonCode, const string &msg)
 
int get_return_code () const
 
string get_error_str () const
 
int get_reason_code () const
 
string get_reason_code_str () const
 
string get_message () const
 
string to_string () const
 

Static Public Member Functions

static string error_str (int rc)
 
static string reason_code_str (int reasonCode)
 
static string printable_error (int rc, int reasonCode=ReasonCode::SUCCESS, const string &msg=string())
 

Protected Attributes

int rc_
 
ReasonCode reasonCode_
 
string msg_
 

Detailed Description

Base mqtt::exception. This wraps the error codes which originate from the underlying C library.

Constructor & Destructor Documentation

◆ exception() [1/4]

mqtt::exception::exception ( int  rc)
inlineexplicit

Creates an MQTT exception.

Parameters
rcThe error return code from the C library.

◆ exception() [2/4]

mqtt::exception::exception ( int  rc,
ReasonCode  reasonCode 
)
inlineexplicit

Creates an MQTT exception.

Parameters
rcThe error return code from the C library.
reasonCodeThe reason code from the server response.

◆ exception() [3/4]

mqtt::exception::exception ( int  rc,
const string msg 
)
inline

Creates an MQTT exception.

Parameters
rcThe error return code from the C library.
msgThe text message for the error.

◆ exception() [4/4]

mqtt::exception::exception ( int  rc,
ReasonCode  reasonCode,
const string msg 
)
inline

Creates an MQTT exception.

Parameters
rcThe error return code from the C library.
reasonCodeThe reason code from the server
msgThe text message for the error.

Member Function Documentation

◆ error_str()

static string mqtt::exception::error_str ( int  rc)
inlinestatic

Gets an error message from an error code.

Parameters
rcThe error code from the C lib
Returns
A string explanation of the error

◆ reason_code_str()

static string mqtt::exception::reason_code_str ( int  reasonCode)
inlinestatic

Gets a string describing the MQTT v5 reason code.

Parameters
reasonCodeThe MQTT v5 reason code.
Returns
A string describing the reason code.

◆ printable_error()

static string mqtt::exception::printable_error ( int  rc,
int  reasonCode = ReasonCode::SUCCESS,
const string msg = string() 
)
inlinestatic

Gets a detailed error message for an error code.

Parameters
rcThe error code from the C lib
reasonCodeThe MQTT v5 reason code
msgAn optional additional message. If none is provided, the error_str message is used.
Returns
A string error message that includes the error code and an explanation message.

◆ get_return_code()

int mqtt::exception::get_return_code ( ) const
inline

Returns the return code for this exception.

◆ get_error_str()

string mqtt::exception::get_error_str ( ) const
inline

Gets a string of the error code.

Returns
A string of the error code.

◆ get_reason_code()

int mqtt::exception::get_reason_code ( ) const
inline

Returns the reason code for this exception. For MQTT v3 connections, this is actually the return code.

◆ get_reason_code_str()

string mqtt::exception::get_reason_code_str ( ) const
inline

Gets a string for the reason code.

Returns
A string for the reason code.

◆ get_message()

string mqtt::exception::get_message ( ) const
inline

Returns the error message for this exception.

◆ to_string()

string mqtt::exception::to_string ( ) const
inline

Gets a string representation of this exception.

Returns
A string representation of this exception.

Field Documentation

◆ rc_

int mqtt::exception::rc_
protected

The error return code from the C library

◆ reasonCode_

ReasonCode mqtt::exception::reasonCode_
protected

The reason code from the server

◆ msg_

string mqtt::exception::msg_
protected

The error message from the C library


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