All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #12
38 lines
558 B
Go
38 lines
558 B
Go
package domain
|
|
|
|
import "errors"
|
|
|
|
var (
|
|
ErrNothingToUpdate = errors.New("nothing to update")
|
|
)
|
|
|
|
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
|
|
}
|