summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/slack-go/slack/internal/misc/misc.go
blob: eab8cdd8c0276e9fc334da8ee279eb302fc5843e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
}