hueplusplus 1.2.0+ds-2
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
hueplusplus::HueAPIResponseException Class Reference

Exception caused by a Hue API "error" response with additional information. More...

#include <hueplusplus/HueException.h>

+ Inheritance diagram for hueplusplus::HueAPIResponseException:
+ Collaboration diagram for hueplusplus::HueAPIResponseException:

Public Member Functions

 HueAPIResponseException (FileInfo fileInfo, int error, std::string address, std::string description)
 Create exception with info from Hue API error.
 
int GetErrorNumber () const noexcept
 Error number from Hue API error response.
 
const std::string & GetAddress () const noexcept
 Address the API call tried to access.
 
const std::string & GetDescription () const noexcept
 Error description.
 
- Public Member Functions inherited from hueplusplus::HueException
 HueException (FileInfo fileInfo, const std::string &message)
 Creates HueException with information about the error and source.
 
const char * what () const noexcept override
 What message of the exception.
 
const FileInfo & GetFile () const noexcept
 Filename and line where the exception was thrown or caused by.
 

Static Public Member Functions

static HueAPIResponseException Create (FileInfo fileInfo, const nlohmann::json &response)
 Creates exception from API response.
 

Additional Inherited Members

- Protected Member Functions inherited from hueplusplus::HueException
 HueException (const char *exceptionName, FileInfo fileInfo, const std::string &message)
 Creates HueException with child class name.
 

Detailed Description

Exception caused by a Hue API "error" response with additional information.

Refer to Hue developer documentation for more detail on specific error codes.

Constructor & Destructor Documentation

◆ HueAPIResponseException()

hueplusplus::HueAPIResponseException::HueAPIResponseException ( FileInfo  fileInfo,
int  error,
std::string  address,
std::string  description 
)

Create exception with info from Hue API error.

Parameters
fileInfoSource of the error. Must not always be the throw location, can also be a calling function which matches the cause better.
errorHue API error code from error response.
addressURI the API call referred to from error response.
descriptionError description from response.

Member Function Documentation

◆ Create()

HueAPIResponseException hueplusplus::HueAPIResponseException::Create ( FileInfo  fileInfo,
const nlohmann::json &  response 
)
static

Creates exception from API response.

Parameters
fileInfoLocation of the cause
responseHue API response. Must contain a member "error" with "type", "address" and "description".
Returns
HueAPIResponseException with info from the response. If response does not contain the required members, they are defaulted to -1 or "".

◆ GetAddress()

const std::string & hueplusplus::HueAPIResponseException::GetAddress ( ) const
noexcept

Address the API call tried to access.

◆ GetDescription()

const std::string & hueplusplus::HueAPIResponseException::GetDescription ( ) const
noexcept

Error description.

◆ GetErrorNumber()

int hueplusplus::HueAPIResponseException::GetErrorNumber ( ) const
noexcept

Error number from Hue API error response.

Refer to Hue developer documentation for meaning of error codes.


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