dcbot/internal/domain/error.go

32 lines
478 B
Go

package domain
type ErrorCode uint8
const (
ErrorCodeUnknown ErrorCode = iota
ErrorCodeEntityNotFound
ErrorCodeValidationError
)
type UserError interface {
error
UserError() string
Code() ErrorCode
}
type RequiredError struct {
Field string
}
func (e RequiredError) Error() string {
return e.Field + ": cannot be blank"
}
func (e RequiredError) UserError() string {
return e.Error()
}
func (e RequiredError) Code() ErrorCode {
return ErrorCodeValidationError
}