Skip to content

Discord error response data discarded #41

@jee7

Description

@jee7

Discord sends back data in the response body when there is a rate limit error.
See: https://discord.com/developers/docs/topics/rate-limits

They say that you should not hard code the retry timeout:

Because we may change rate limits at any time and rate limits can be different per application, rate limits should not be hard coded into your bot/application. In order to properly support our dynamic rate limits, your bot/application should parse for our rate limits in response headers and locally prevent exceeding the limits as they change.

Right now the RequestException is caught and a CouldNotSendNotification exception is thrown. The latter only includes the message keyword from the response sent by Discord API. The other keywords like retry_after and global are being discarded.

One fix for this could be to include the original RequestException exception as the previous exception to the thrown CouldNotSendNotification. Exceptions have 3 constructor arguments, the message, code and previous exception. Only the message part is currently used. Setting the previous exception should make it possible for the Laravel app to get the body of the original Discord response from the original exception and parse out the retry_after or other data.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions