Loading...
Searching...
No Matches
mqtt::exception Class Reference

`#include <exception.h>`

Inheritance diagram for mqtt::exception:

## 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, ReasonCode reasonCode=ReasonCode::SUCCESS, const string &msg=string())

## Static Protected Member Functions

static ReasonCode | reason_code (int rc, ReasonCode reasonCode)

## 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 | ) |

inline explicit

Creates an MQTT exception.

Parameters

  rc | The error return code from the C library.

## exception() [2/4]

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

inline explicit

Creates an MQTT exception.

Parameters

  rc | The error return code from the C library.
  reasonCode | The reason code from the server response.

## exception() [3/4]

mqtt::exception::exception | ( | int | rc,
|  | const string & | msg )

inline

Creates an MQTT exception.

Parameters

  rc | The error return code from the C library.
  msg | The text message for the error.

## exception() [4/4]

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

inline

Creates an MQTT exception.

Parameters

  rc | The error return code from the C library.
  reasonCode | The reason code from the server
  msg | The text message for the error.

## Member Function Documentation

## reason_code()

ReasonCode mqtt::exception::reason_code | ( | int | rc,
|  | ReasonCode | reasonCode )

inline static protected

See if the return code is actually a reason code error value

## error_str()

string mqtt::exception::error_str | ( | int | rc | ) |

inline static

Gets an error message from an error code.

Parameters

  rc | The error code from the C lib

Returns
  A string explanation of the error

## reason_code_str()

string mqtt::exception::reason_code_str | ( | int | reasonCode | ) |

inline static

Gets a string describing the MQTT v5 reason code.

Parameters

  reasonCode | The MQTT v5 reason code.

Returns
  A string describing the reason code.

## printable_error()

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

inline static

Gets a detailed error message for an error code.

Parameters

  rc | The error code from the C lib
  reasonCode | The MQTT v5 reason code
  msg | An 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:

- exception.h