Module slack_sdk.errors

Errors that can be raised by this SDK

Expand source code
"""Errors that can be raised by this SDK"""


class SlackClientError(Exception):
    """Base class for Client errors"""


class BotUserAccessError(SlackClientError):
    """Error raised when an 'xoxb-*' token is
    being used for a Slack API method that only accepts 'xoxp-*' tokens.
    """


class SlackRequestError(SlackClientError):
    """Error raised when there's a problem with the request that's being submitted."""


class SlackApiError(SlackClientError):
    """Error raised when Slack does not send the expected response.

    Attributes:
        response (SlackResponse): The SlackResponse object containing all of the data sent back from the API.

    Note:
        The message (str) passed into the exception is used when
        a user converts the exception to a str.
        i.e. str(SlackApiError("This text will be sent as a string."))
    """

    def __init__(self, message, response):
        msg = f"{message}\nThe server responded with: {response}"
        self.response = response
        super(SlackApiError, self).__init__(msg)


class SlackTokenRotationError(SlackClientError):
    """Error raised when the oauth.v2.access call for token rotation fails"""

    api_error: SlackApiError

    def __init__(self, api_error: SlackApiError):
        self.api_error = api_error


class SlackClientNotConnectedError(SlackClientError):
    """Error raised when attempting to send messages over the websocket when the
    connection is closed."""


class SlackObjectFormationError(SlackClientError):
    """Error raised when a constructed object is not valid/malformed"""


class SlackClientConfigurationError(SlackClientError):
    """Error raised because of invalid configuration on the client side:
    * when attempting to send messages over the websocket when the connection is closed.
    * when external system (e.g., Amazon S3) configuration / credentials are not correct
    """

Classes

class BotUserAccessError (*args, **kwargs)

Error raised when an 'xoxb-' token is being used for a Slack API method that only accepts 'xoxp-' tokens.

Expand source code
class BotUserAccessError(SlackClientError):
    """Error raised when an 'xoxb-*' token is
    being used for a Slack API method that only accepts 'xoxp-*' tokens.
    """

Ancestors

class SlackApiError (message, response)

Error raised when Slack does not send the expected response.

Attributes

response : SlackResponse
The SlackResponse object containing all of the data sent back from the API.

Note

The message (str) passed into the exception is used when a user converts the exception to a str. i.e. str(SlackApiError("This text will be sent as a string."))

Expand source code
class SlackApiError(SlackClientError):
    """Error raised when Slack does not send the expected response.

    Attributes:
        response (SlackResponse): The SlackResponse object containing all of the data sent back from the API.

    Note:
        The message (str) passed into the exception is used when
        a user converts the exception to a str.
        i.e. str(SlackApiError("This text will be sent as a string."))
    """

    def __init__(self, message, response):
        msg = f"{message}\nThe server responded with: {response}"
        self.response = response
        super(SlackApiError, self).__init__(msg)

Ancestors

class SlackClientConfigurationError (*args, **kwargs)

Error raised because of invalid configuration on the client side: * when attempting to send messages over the websocket when the connection is closed. * when external system (e.g., Amazon S3) configuration / credentials are not correct

Expand source code
class SlackClientConfigurationError(SlackClientError):
    """Error raised because of invalid configuration on the client side:
    * when attempting to send messages over the websocket when the connection is closed.
    * when external system (e.g., Amazon S3) configuration / credentials are not correct
    """

Ancestors

class SlackClientError (*args, **kwargs)

Base class for Client errors

Expand source code
class SlackClientError(Exception):
    """Base class for Client errors"""

Ancestors

  • builtins.Exception
  • builtins.BaseException

Subclasses

class SlackClientNotConnectedError (*args, **kwargs)

Error raised when attempting to send messages over the websocket when the connection is closed.

Expand source code
class SlackClientNotConnectedError(SlackClientError):
    """Error raised when attempting to send messages over the websocket when the
    connection is closed."""

Ancestors

class SlackObjectFormationError (*args, **kwargs)

Error raised when a constructed object is not valid/malformed

Expand source code
class SlackObjectFormationError(SlackClientError):
    """Error raised when a constructed object is not valid/malformed"""

Ancestors

class SlackRequestError (*args, **kwargs)

Error raised when there's a problem with the request that's being submitted.

Expand source code
class SlackRequestError(SlackClientError):
    """Error raised when there's a problem with the request that's being submitted."""

Ancestors

class SlackTokenRotationError (api_error: SlackApiError)

Error raised when the oauth.v2.access call for token rotation fails

Expand source code
class SlackTokenRotationError(SlackClientError):
    """Error raised when the oauth.v2.access call for token rotation fails"""

    api_error: SlackApiError

    def __init__(self, api_error: SlackApiError):
        self.api_error = api_error

Ancestors

Class variables

var api_errorSlackApiError