Add static code analysis to CI test (#1197)

This commit is contained in:
Ta-Ching Chen
2019-06-02 14:29:38 +08:00
committed by GitHub
parent 1562cba420
commit 93d4f2c77a
23 changed files with 130 additions and 146 deletions
+13 -5
View File
@@ -87,6 +87,14 @@ func (err Error) HTTPStatus() int {
return code
}
func (err Error) Description() string {
idx := int(err.Code)
if idx < 0 || idx > len(errorDescriptions)-1 {
return ""
}
return errorDescriptions[idx]
}
func GetHTTPError(err error) (int, string) {
var msg string
var code int
@@ -101,12 +109,12 @@ func GetHTTPError(err error) (int, string) {
return code, msg
}
func (err Error) Description() string {
idx := int(err.Code)
if idx < 0 || idx > len(errorDescriptions)-1 {
return ""
func IsNotFound(err error) bool {
fe, ok := err.(Error)
if !ok {
return false
}
return errorDescriptions[idx]
return fe.Code == ErrorNotFound
}
const (