Slack
Dispatch provides a built-in integration with Slack SDK, offering error handling out of the box. It’s enabled by default and it takes no extra code to set it up.
Exception handling
SlackApiError
Depending on the response.status_code
attribute, a different Dispatch behavior is applied.
HTTP status code | Description | Dispatch status |
---|---|---|
1xx | Informational | Status.PERMANENT_ERROR |
2xx | Successful | Status.OK |
3xx | Redirection | Status.PERMANENT_ERROR |
3xx | Redirection | Status.PERMANENT_ERROR |
4xx | Client error | Status.PERMANENT_ERROR |
400 | Bad request | Status.INVALID_ARGUMENT |
401 | Unauthorized | Status.UNAUTHENTICATED |
403 | Forbidden | Status.PERMISSION_DENIED |
404 | Not found | Status.NOT_FOUND |
408 | Request timeout | Status.TIMEOUT |
429 | Too many requests | Status.THROTTLED |
5xx | Server error | Status.TEMPORARY_ERROR |
501 | Not implemented | Status.PERMANENT_ERROR |
SlackClientError
Returns Status.TEMPORARY_ERROR
, unless exception is SlackApiError
, since SlackClientError
is a parent class of that exception. Learn more in Slack SDK documentation.
Response handling
If a function returns slack_sdk.web.SlackResponse
instance, Dispatch looks at the status_code
attribute and determines behavior the same way as SlackApiError
exception.