Discord Social SDK
|
Struct that stores information about the result of an SDK function call.
Functions can fail for a few reasons including:
The ClientResult::Type field is used to to distinguish between the above types of failures
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. | |
|
noexcept |
Move constructor for ClientResult.
discordpp::ClientResult::ClientResult | ( | const ClientResult & | arg0 | ) |
Copy constructor for ClientResult.
std::string discordpp::ClientResult::Error | ( | ) | const |
A description of the error that occurred.
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
|
inline |
Returns true if the instance contains a valid object.
|
noexcept |
Move assignment operator for ClientResult.
ClientResult & discordpp::ClientResult::operator= | ( | const ClientResult & | arg0 | ) |
Copy assignment operator for ClientResult.
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
bool discordpp::ClientResult::Retryable | ( | ) | const |
Indicates if, although an API request failed, it is safe and recommended to retry it.
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.
void discordpp::ClientResult::SetError | ( | std::string | Error | ) |
Setter for ClientResult::Error.
void discordpp::ClientResult::SetErrorCode | ( | int32_t | ErrorCode | ) |
Setter for ClientResult::ErrorCode.
void discordpp::ClientResult::SetResponseBody | ( | std::string | ResponseBody | ) |
Setter for ClientResult::ResponseBody.
void discordpp::ClientResult::SetRetryable | ( | bool | Retryable | ) |
Setter for ClientResult::Retryable.
void discordpp::ClientResult::SetRetryAfter | ( | float | RetryAfter | ) |
Setter for ClientResult::RetryAfter.
void discordpp::ClientResult::SetStatus | ( | discordpp::HttpStatusCode | Status | ) |
Setter for ClientResult::Status.
void discordpp::ClientResult::SetSuccessful | ( | bool | Successful | ) |
Setter for ClientResult::Successful.
void discordpp::ClientResult::SetType | ( | discordpp::ErrorType | Type | ) |
Setter for ClientResult::Type.
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
bool discordpp::ClientResult::Successful | ( | ) | const |
Equivalent to type == ErrorType::None.
std::string discordpp::ClientResult::ToString | ( | ) | const |
Returns the error message if any of the ClientResult.
discordpp::ErrorType discordpp::ClientResult::Type | ( | ) | const |
The type of error that occurred. See ErrorType for more information.
|
static |
Uninitialized instance of ClientResult.