revert: return from comfylite to normal sqlite

This commit is contained in:
Tigor Hutasuhut 2024-05-27 14:29:09 +07:00
parent addf634820
commit 7e29cf7e55

View file

@ -2,6 +2,7 @@ package errs
import ( import (
"errors" "errors"
"net/http"
) )
func FindCodeOrDefault(err error, def int) int { func FindCodeOrDefault(err error, def int) int {
@ -52,3 +53,22 @@ func HTTPMessage(err error) (code int, message string) {
message = FindMessage(err) message = FindMessage(err)
return code, message return code, message
} }
func HasCode(err error, code int) bool {
return FindCodeOrDefault(err, http.StatusInternalServerError) == code
}
func Source(err error) error {
if err == nil {
return nil
}
if _, ok := err.(Error); !ok {
return err
}
for unwrap := errors.Unwrap(err); unwrap != nil; unwrap = errors.Unwrap(unwrap) {
if _, ok := unwrap.(Error); !ok {
return unwrap
}
}
return err
}