dcbot/internal/domain/error.go
Dawid Wysokiński d94b7bcbed
All checks were successful
continuous-integration/drone/push Build is passing
feat: add a new cmd - group add (#2)
Reviewed-on: #2
2022-10-03 05:19:33 +00:00

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
}