dcbot/internal/domain/error.go
Dawid Wysokiński 6415b162de
All checks were successful
continuous-integration/drone/push Build is passing
feat: errors - i18n (#111)
Reviewed-on: #111
2023-06-27 12:00:35 +00:00

35 lines
528 B
Go

package domain
import (
"errors"
"fmt"
)
var ErrNothingToUpdate = errors.New("nothing to update")
type TranslatableError interface {
error
Slug() string
Params() map[string]any
}
type RequiredError struct {
Field string
}
var _ TranslatableError = RequiredError{}
func (e RequiredError) Error() string {
return fmt.Sprintf("%s can't be blank", e.Field)
}
func (e RequiredError) Slug() string {
return "required"
}
func (e RequiredError) Params() map[string]any {
return map[string]any{
"Field": e.Field,
}
}