Skip to content

Commit d9622c3

Browse files
authored
Merge pull request #11 from objenious/io/timeout
add io timeout error
2 parents 77900ab + f388c67 commit d9622c3

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ go:
44
- 1.13.x
55
- 1.14.x
66
- 1.15.x
7+
- 1.16.x

http.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ func HTTPStatusCode(err error) int {
5151
// package database/sql
5252
case "sql: no rows in result set":
5353
return http.StatusNotFound
54+
case "i/o timeout":
55+
return http.StatusRequestTimeout
5456
}
5557
cause, ok := err.(causer)
5658
if !ok {

retryable_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package errorutil
22

33
import (
44
"errors"
5-
"fmt"
65
"net/http"
76
"testing"
87

@@ -12,7 +11,10 @@ import (
1211
type retryable bool
1312

1413
func (err retryable) Error() string {
15-
return fmt.Sprintf("%v", err)
14+
if err {
15+
return "true"
16+
}
17+
return "false"
1618
}
1719

1820
func (err retryable) Retryable() bool {
@@ -60,7 +62,6 @@ func TestIsRetryable(t *testing.T) {
6062
{pkgerrors.Wrap(httpError(http.StatusForbidden), "bar"), false},
6163
{ForbiddenError(errors.New("foo")), false},
6264

63-
6465
{NotRetryableError(httpError(http.StatusBadGateway)), false},
6566
{NotRetryableError(pkgerrors.Wrap(httpError(http.StatusBadGateway), "bar")), false},
6667
{NotRetryableError(httpError(http.StatusInternalServerError)), false},

0 commit comments

Comments
 (0)