24 lines
575 B
Go
24 lines
575 B
Go
package domain
|
|
|
|
import "errors"
|
|
|
|
var (
|
|
ErrNotFound = errors.New("not found")
|
|
ErrForbidden = errors.New("forbidden")
|
|
ErrConflict = errors.New("conflict")
|
|
ErrInvalidInput = errors.New("invalid input")
|
|
)
|
|
|
|
// ValidationError carries a user-safe explanation for invalid input.
|
|
type ValidationError struct {
|
|
Message string
|
|
}
|
|
|
|
func (e ValidationError) Error() string { return e.Message }
|
|
|
|
func (e ValidationError) Is(target error) bool { return target == ErrInvalidInput }
|
|
|
|
func NewValidationError(message string) error {
|
|
return ValidationError{Message: message}
|
|
}
|