APIError
ErrorOn this page
APIError is raised or passed to a REST callback when an operation fails. Read name and message; REST errors may also expose HTTP status and Discord error codes.
Constructor
APIError.new(message, extra) The class table is callable, so APIError(message, extra) is the same as .new.
| Name | Type | Required | Behavior |
|---|---|---|---|
message |
any |
required | Passed through to the implementation as written. |
extra |
any |
optional | Passed through to the implementation as written. |
local discord = require("discord")
local object = discord.APIError({}, {})Properties
- Name
code- Type
number- Access
- readonly
- Description
- Instance field
APIError.code. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this APIError.
- Name
extra- Type
table- Access
- readonly
- Description
- Instance field
APIError.extra. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this APIError.
- Name
message- Type
string- Access
- readonly
- Description
- Instance field
APIError.message. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this APIError.
- Name
method- Type
string- Access
- readonly
- Description
- Instance field
APIError.method. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this APIError.
- Name
name- Type
string- Access
- readonly
- Description
- Display name of this APIError.
- Availability
- Populated from the Gateway/REST payload or constructor for this APIError.
- Name
path- Type
string- Access
- readonly
- Description
- Instance field
APIError.path. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this APIError.
- Name
retryAfter- Type
number- Access
- readonly
- Description
- Instance field
APIError.retryAfter. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this APIError.
- Name
status- Type
number- Access
- readonly
- Description
- Instance field
APIError.status. Read it after the object is constructed or wrapped from Gateway/REST data. - Availability
- Populated from the Gateway/REST payload or constructor for this APIError.
Methods
Performs new on this APIError. Call it from bot code when you need that operation on the current object.
Signature
APIError.new(message, extra) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
message |
any |
required | Passed through to the implementation as written. |
extra |
any |
optional | Passed through to the implementation as written. |
Returns
any.
Example
local discord = require("discord")
-- object is a APIError
APIError.new(message, extra)APIError:raise()
#Performs raise on this APIError. Call it from bot code when you need that operation on the current object.
Signature
APIError:raise(level) Parameters
| Name | Type | Required | Behavior |
|---|---|---|---|
level |
any |
required | Passed through to the implementation as written. |
Returns
any.
Throws
A DiscordLua error when arguments are invalid or the request fails without a callback.
Example
local discord = require("discord")
-- object is a APIError
object:raise(level)Examples
local discord = require("discord")
local object = discord.APIError({})Related APIs
AuthenticationError · DiscordLuaError · GatewayError · HTTPError · PermissionError · RateLimitError · RuntimeError · ValidationError
Version: discord 1.2.4 · runtime 1.0.0