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 }