Skip to content

Commit 3fded96

Browse files
author
jojoliang
committed
add IsNoSuchKeyError function
1 parent b427226 commit 3fded96

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

error.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,17 @@ func checkResponse(r *http.Response) error {
4747
}
4848
return errorResponse
4949
}
50+
51+
func IsNoSuchKeyError(e error) bool {
52+
if e == nil {
53+
return false
54+
}
55+
err, ok := e.(*ErrorResponse)
56+
if !ok {
57+
return false
58+
}
59+
if err.Response != nil && err.Response.StatusCode == 404 && err.Code == "NoSuchKey" {
60+
return true
61+
}
62+
return false
63+
}

0 commit comments

Comments
 (0)