shop/shop_error/errors.go
Frederik Löffert ebdd0e529f customer soft lock improved
customer version history dropped
2020-06-15 14:42:01 +02:00

28 lines
804 B
Go

package shop_error
import (
"errors"
"strings"
)
// ErrorVersionConflict version conflict while upserting to mongo
var ErrorVersionConflict = errors.New("version conflict")
// ErrorDuplicateKey an index key constraint mismatch
var ErrorDuplicateKey = errors.New("duplicate key")
const (
ErrorAlreadyExists = "already existing in db" // do not change, this string is returned by MongoDB
ErrorNotInDatabase = "not found" // do not change, this string is returned by MongoDB
ErrorNotFound = "Error: Not Found: "
ErrorRequiredFieldMissing = "Error: A required field is missing!"
)
// ErrorIs returns true, if err is of kind e, else false
func IsError(err error, e string) bool {
if err == nil {
return false
}
return strings.HasPrefix(err.Error(), e)
}