diff options
Diffstat (limited to 'vendor/github.com/slack-go/slack/internal/misc/misc.go')
-rw-r--r-- | vendor/github.com/slack-go/slack/internal/misc/misc.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/vendor/github.com/slack-go/slack/internal/misc/misc.go b/vendor/github.com/slack-go/slack/internal/misc/misc.go new file mode 100644 index 00000000..eab8cdd8 --- /dev/null +++ b/vendor/github.com/slack-go/slack/internal/misc/misc.go @@ -0,0 +1,28 @@ +package misc + +import ( + "fmt" + "net/http" +) + +// StatusCodeError represents an http response error. +// type httpStatusCode interface { HTTPStatusCode() int } to handle it. +type StatusCodeError struct { + Code int + Status string +} + +func (t StatusCodeError) Error() string { + return fmt.Sprintf("slack server error: %s", t.Status) +} + +func (t StatusCodeError) HTTPStatusCode() int { + return t.Code +} + +func (t StatusCodeError) Retryable() bool { + if t.Code >= 500 || t.Code == http.StatusTooManyRequests { + return true + } + return false +} |