Rework error messages

This commit reworks error messages for all commands and makes sure they
pass liniting.
This commit is contained in:
Tom Wiesing 2023-03-09 11:13:19 +01:00
parent d22784e6f5
commit c31c46ee44
No known key found for this signature in database
40 changed files with 249 additions and 110 deletions

View file

@ -14,6 +14,7 @@ import (
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/php"
"github.com/FAU-CDI/wisski-distillery/pkg/fsx"
"github.com/tkw1536/pkglib/collection"
"golang.org/x/exp/slices"
_ "embed"
)
@ -110,7 +111,7 @@ func (prefixes *Prefixes) blocked() ([]string, error) {
}
func hasAnyPrefix(candidate string, prefixes []string) bool {
return collection.Any(
return slices.ContainsFunc(
prefixes,
func(prefix string) bool {
return strings.HasPrefix(candidate, prefix)

View file

@ -11,7 +11,7 @@ import (
"github.com/tkw1536/pkglib/password"
)
var errGetValidator = errors.New("GetPasswordValidator: Unknown Error")
var errGetValidator = errors.New("`GetPasswordValidator': unknown error")
func (u *Users) GetPasswordValidator(ctx context.Context, username string) (pv PasswordValidator, err error) {
server := u.Dependencies.PHP.NewServer()
@ -53,7 +53,7 @@ func (pv PasswordValidator) Check(ctx context.Context, password string) bool {
return bool(result)
}
var errPasswordUsername = errors.New("username === password")
var errPasswordUsername = errors.New("username equals password")
func (pv PasswordValidator) CheckDictionary(ctx context.Context, writer io.Writer) error {
var counter int

View file

@ -32,7 +32,7 @@ func (u *Users) All(ctx context.Context, server *phpx.Server) (users []status.Dr
return
}
var errLoginUnknownError = errors.New("Login: Unknown Error")
var errLoginUnknownError = errors.New("`Login': unknown error")
// Login generates a login link for the user with the given username
func (u *Users) Login(ctx context.Context, server *phpx.Server, username string) (dest *url.URL, err error) {
@ -75,7 +75,7 @@ func (u *Users) LoginWithOpt(ctx context.Context, server *phpx.Server, username
return
}
var errSetPassword = errors.New("SetPassword: Unknown Error")
var errSetPassword = errors.New("`SetPassword': unknown error")
// SetPassword sets the password for a given user
func (u *Users) SetPassword(ctx context.Context, server *phpx.Server, username, password string) error {