Browse Source

remove equals and use error.Is

cleanup
Lars Hoogestraat 7 months ago
parent
commit
f1dc6fa95a
2 changed files with 1 additions and 18 deletions
  1. +1
    -1
      handler/account.go
  2. +0
    -17
      httperror/error.go

+ 1
- 1
handler/account.go View File

@ -297,7 +297,7 @@ func ForgotPasswordPostHandler(ctx *middleware.AppContext, w http.ResponseWriter
u, err := ctx.UserService.GetByMail(email)
if err != nil {
if httperror.Equals(err, sql.ErrNoRows) {
if errors.Is(err, sql.ErrNoRows) {
logger.Log.Error(err)
return &middleware.Template{
RedirectPath: "admin",


+ 0
- 17
httperror/error.go View File

@ -84,23 +84,6 @@ func ValueRequired(param string) *Error {
}
}
func Equals(a error, b error) bool {
v, ok := a.(*Error)
v2, ok2 := b.(*Error)
if ok && ok2 {
return v.Err == v2.Err
} else if !ok && !ok2 {
return v == v2
} else if ok && !ok2 {
return v.Err == b
} else if !ok && ok2 {
return a == v2.Err
}
return false
}
func (e Error) Error() string {
return fmt.Sprintf("code=[%d], error=[%s], displayMsg=[%s]", e.HTTPStatus, e.Err.Error(), e.DisplayMsg)
}

Loading…
Cancel
Save