Skip to content
Raven Ravener edited this page Oct 17, 2022 · 4 revisions

Discordia utilizes multiple returns in order to convey error messages. Most API methods like message:delete() will return data or nil, err. The first return value may be nil and thus should be properly handled. If the first return value is nil then the second return value will be a string containing error information which will be very useful for debugging.

Selective Erroring

pcall and Discordia

Discordia functions will generally not throw an error unless erroneous data is provided to it. As such, using pcall around Discordia methods is unneccesary, but in such a case you should be verifying the integrity of the data you provide to these methods.

Using assert

Because of the how values and errors are returned in Discordia, you can safely assert discordia methods if you would prefer that you get a proper error that can be caught. An example of how to do this is local success = assert(message:delete()), which will return the value of message:delete()'s return if it succeeds, but will throw an error that can be caught if it does not (in this case, usually due to not having permission).

Discordia Logging

Discordia's Logger provides all of the Logging functions of the library.

In-Depth Log Levels

Enumerations#logLevel

level description
none absolutely nothing
error API request failures (HTTP 4xx/5xx), sharding issues, authentication issues
warning uncached objects and unhandled gateway events, unacknowledged heartbeats, gateway reconnections
info connecting to the gateway, launching shards, receiving select gateway events
debug all HTTP requests, all gateway events, gateway debugging information
Clone this wiki locally