Rise
The Vieneo Province
Loading...
Searching...
No Matches
discordpp::ClientResult Class Reference

Struct that stores information about the result of an SDK function call. More...

#include <discordpp.h>

Collaboration diagram for discordpp::ClientResult:
[legend]

Public Member Functions

 ClientResult (ClientResult &&other) noexcept
 Move constructor for ClientResult.
ClientResult & operator= (ClientResult &&other) noexcept
 Move assignment operator for ClientResult.
 operator bool () const
 Returns true if the instance contains a valid object.
 ClientResult (const ClientResult &arg0)
 Copy constructor for ClientResult.
ClientResult & operator= (const ClientResult &arg0)
 Copy assignment operator for ClientResult.
std::string ToString () const
 Returns the error message if any of the ClientResult.
discordpp::ErrorType Type () const
 The type of error that occurred. See ErrorType for more information.
void SetType (discordpp::ErrorType Type)
 Setter for ClientResult::Type.
std::string Error () const
 A description of the error that occurred.
void SetError (std::string Error)
 Setter for ClientResult::Error.
int32_t ErrorCode () const
 A more detailed error code for this failure. Currently the only use of this is when an API request is made to Discord's backend and that fails with a specific error, that error will be included in this field.
void SetErrorCode (int32_t ErrorCode)
 Setter for ClientResult::ErrorCode.
discordpp::HttpStatusCode Status () const
 The HTTP status code of the API call.
void SetStatus (discordpp::HttpStatusCode Status)
 Setter for ClientResult::Status.
std::string ResponseBody () const
 The full HTTP response body, which will usually be a JSON string.
void SetResponseBody (std::string ResponseBody)
 Setter for ClientResult::ResponseBody.
bool Successful () const
 Equivalent to type == ErrorType::None.
void SetSuccessful (bool Successful)
 Setter for ClientResult::Successful.
bool Retryable () const
 Indicates if, although an API request failed, it is safe and recommended to retry it.
void SetRetryable (bool Retryable)
 Setter for ClientResult::Retryable.
float RetryAfter () const
 When a user is being rate limited by Discord (and so status == 429), this field should be set and is the number of seconds to wait before trying again.
void SetRetryAfter (float RetryAfter)
 Setter for ClientResult::RetryAfter.

Static Public Attributes

static const ClientResult nullobj
 Uninitialized instance of ClientResult.

Detailed Description

Struct that stores information about the result of an SDK function call.

Functions can fail for a few reasons including:

  • The Client is not yet ready and able to perform the action.
  • The inputs passed to the function are invalid.
  • The function makes an API call to Discord's backend which returns an error.
  • The user is offline.

The ClientResult::Type field is used to to distinguish between the above types of failures

Definition at line 1455 of file discordpp.h.

Constructor & Destructor Documentation

◆ ClientResult() [1/2]

discordpp::ClientResult::ClientResult ( ClientResult && other)
noexcept

Move constructor for ClientResult.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClientResult() [2/2]

discordpp::ClientResult::ClientResult ( const ClientResult & arg0)

Copy constructor for ClientResult.

Here is the call graph for this function:

Member Function Documentation

◆ Error()

std::string discordpp::ClientResult::Error ( ) const

A description of the error that occurred.

Here is the caller graph for this function:

◆ ErrorCode()

int32_t discordpp::ClientResult::ErrorCode ( ) const

A more detailed error code for this failure. Currently the only use of this is when an API request is made to Discord's backend and that fails with a specific error, that error will be included in this field.

Many of these error codes are documented at: https://discord.com/developers/docs/topics/opcodes-and-status-codes#json

This will only be set if the type of error is ErrorType::HTTPError

Here is the caller graph for this function:

◆ operator bool()

discordpp::ClientResult::operator bool ( ) const
inline

Returns true if the instance contains a valid object.

Definition at line 1476 of file discordpp.h.

◆ operator=() [1/2]

ClientResult & discordpp::ClientResult::operator= ( ClientResult && other)
noexcept

Move assignment operator for ClientResult.

Here is the call graph for this function:

◆ operator=() [2/2]

ClientResult & discordpp::ClientResult::operator= ( const ClientResult & arg0)

Copy assignment operator for ClientResult.

Here is the call graph for this function:

◆ ResponseBody()

std::string discordpp::ClientResult::ResponseBody ( ) const

The full HTTP response body, which will usually be a JSON string.

The error format here is a bit more complicated because Discord's API tries to make it clear which field from the request is causing the error. Documentation on the format of these errors is here: https://discord.com/developers/docs/reference#error-messages

This will only be set if the type of error is ErrorType::HTTPError

Here is the caller graph for this function:

◆ Retryable()

bool discordpp::ClientResult::Retryable ( ) const

Indicates if, although an API request failed, it is safe and recommended to retry it.

Here is the caller graph for this function:

◆ RetryAfter()

float discordpp::ClientResult::RetryAfter ( ) const

When a user is being rate limited by Discord (and so status == 429), this field should be set and is the number of seconds to wait before trying again.

Here is the caller graph for this function:

◆ SetError()

void discordpp::ClientResult::SetError ( std::string Error)

Setter for ClientResult::Error.

Here is the call graph for this function:

◆ SetErrorCode()

void discordpp::ClientResult::SetErrorCode ( int32_t ErrorCode)

Setter for ClientResult::ErrorCode.

Here is the call graph for this function:

◆ SetResponseBody()

void discordpp::ClientResult::SetResponseBody ( std::string ResponseBody)

Setter for ClientResult::ResponseBody.

Here is the call graph for this function:

◆ SetRetryable()

void discordpp::ClientResult::SetRetryable ( bool Retryable)

Setter for ClientResult::Retryable.

Here is the call graph for this function:

◆ SetRetryAfter()

void discordpp::ClientResult::SetRetryAfter ( float RetryAfter)

Setter for ClientResult::RetryAfter.

Here is the call graph for this function:

◆ SetStatus()

void discordpp::ClientResult::SetStatus ( discordpp::HttpStatusCode Status)

Setter for ClientResult::Status.

Here is the call graph for this function:

◆ SetSuccessful()

void discordpp::ClientResult::SetSuccessful ( bool Successful)

Setter for ClientResult::Successful.

Here is the call graph for this function:

◆ SetType()

void discordpp::ClientResult::SetType ( discordpp::ErrorType Type)

Setter for ClientResult::Type.

Here is the call graph for this function:

◆ Status()

discordpp::HttpStatusCode discordpp::ClientResult::Status ( ) const

The HTTP status code of the API call.

This will only be set if the type of error is ErrorType::HTTPError

Here is the caller graph for this function:

◆ Successful()

bool discordpp::ClientResult::Successful ( ) const

Equivalent to type == ErrorType::None.

Here is the caller graph for this function:

◆ ToString()

std::string discordpp::ClientResult::ToString ( ) const

Returns the error message if any of the ClientResult.

◆ Type()

discordpp::ErrorType discordpp::ClientResult::Type ( ) const

The type of error that occurred. See ErrorType for more information.

Here is the caller graph for this function:

Member Data Documentation

◆ nullobj

const ClientResult discordpp::ClientResult::nullobj
static

Uninitialized instance of ClientResult.

Definition at line 1474 of file discordpp.h.


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