Skip to content

DiscordError

Internal API

These classes are for internal use only.

Users should interact with Client and other public API classes instead.


error

DiscordError

Bases: Exception


              flowchart TD
              scurrypy.core.error.DiscordError[DiscordError]

              

              click scurrypy.core.error.DiscordError href "" "scurrypy.core.error.DiscordError"
            

Represents a Discord API error.

Initialize the error with Discord's response. Extracts reason, code, and walks the nested errors.

Parameters:

  • data (JSON) –

    Discord's error JSON

data = data instance-attribute

status = status instance-attribute

reason = data.get('message', data) instance-attribute

code = data.get('code', 'Unknown Code') instance-attribute

error_data: HTTPResponse = data.get('errors', {}) instance-attribute

details = self.walk(self.error_data) instance-attribute

is_fatal = status in (401, 403) instance-attribute

full_message = f'{self.reason} ({self.code})' instance-attribute

walk

Recursively traverses errors field to flatten nested validation errors into (path, message).

Parameters:

  • node (HTTPResponse) –

    current error level

  • path (list[str], default: None ) –

    path to this error level

Returns:

  • list[tuple[str, str]]

    list of errors