card_id/common/errs/errors.go

27 lines
448 B
Go
Raw Normal View History

2022-04-13 23:09:58 +00:00
package errs
import (
"fmt"
"strings"
)
func e(prefix string, f string, args ...any) error {
return fmt.Errorf("%s: "+f, prefix, args)
}
func Logic(f string, a ...any) error {
return e("logic", f, a)
}
func IsLogic(err error) bool {
return strings.HasPrefix("logic", err.Error())
}
func Invalid(f string, a ...any) error {
return e("invalid", f, a)
}
func IsInvalid(err error) bool {
return strings.HasPrefix("invalid", err.Error())
}