Debian Codegraph @

status_code_error.go

raw symbols SCIP
1 package slack
2
3 import (
4 "fmt"
5 "net/http"
6 )
7
8 // StatusCodeError represents an http response error.
9 // type httpStatusCode interface { HTTPStatusCode() int } to handle it.
10 type StatusCodeError struct {
11 Code int
12 Status string
13 }
14
15 func (t StatusCodeError) Error() string {
16 return fmt.Sprintf("slack server error: %s", t.Status)
17 }
18
19 func (t StatusCodeError) HTTPStatusCode() int {
20 return t.Code
21 }
22
23 func (t StatusCodeError) Retryable() bool {
24 if t.Code >= 500 || t.Code == http.StatusTooManyRequests {
25 return true
26 }
27 return false
28 }