rum-goggles/v1/internal/models/error.go

38 lines
1.1 KiB
Go
Raw Normal View History

package models
import "fmt"
const (
pkgName = "models"
ErrAccountInvalidUsername ValidatorError = "invalid account username"
ErrAccountInvalidID ValidatorError = "invalid account id"
ErrChannelInvalidAccountID ValidatorError = "invalid channel account id"
ErrChannelInvalidApiKey ValidatorError = "invalid channel API key"
ErrChannelInvalidCID ValidatorError = "invalid channel CID"
2024-04-04 14:46:14 +00:00
ErrChannelInvalidID ValidatorError = "invalid channel ID"
ErrChannelInvalidName ValidatorError = "invalid channel name"
2024-05-02 19:30:25 +00:00
ErrChatbotInvalidID ValidatorError = "invalid chatbot id"
ErrChatbotInvalidName ValidatorError = "invalid chatbot name"
ErrChatbotRuleInvalidID ValidatorError = "invalid chatbot rule id"
ErrChatbotRuleInvalidRule ValidatorError = "invalid chatbot rule rule"
)
func pkgErr(prefix string, err error) error {
pkgErr := pkgName
if prefix != "" {
pkgErr = fmt.Sprintf("%s: %s", pkgErr, prefix)
}
return fmt.Errorf("%s: %v", pkgErr, err)
}
type ValidatorError string
func (e ValidatorError) Error() string {
return string(e)
}