common-errors.go: moved here some errors
This commit is contained in:
parent
aa1338cd51
commit
624318d84e
@ -8,6 +8,20 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func errTooFewParams(minArgs, maxArgs, argCount int) (err error) {
|
||||||
|
if maxArgs < 0 {
|
||||||
|
err = fmt.Errorf("too few params -- expected %d or more, got %d", minArgs, argCount)
|
||||||
|
} else {
|
||||||
|
err = fmt.Errorf("too few params -- expected %d, got %d", minArgs, argCount)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func errTooMuchParams(maxArgs, argCount int) (err error) {
|
||||||
|
err = fmt.Errorf("too much params -- expected %d, got %d", maxArgs, argCount)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// --- General errors
|
// --- General errors
|
||||||
|
|
||||||
func errCantConvert(funcName string, value any, kind string) error {
|
func errCantConvert(funcName string, value any, kind string) error {
|
||||||
@ -24,9 +38,9 @@ func errDivisionByZero(funcName string) error {
|
|||||||
|
|
||||||
// --- Parameter errors
|
// --- Parameter errors
|
||||||
|
|
||||||
func errOneParam(funcName string) error {
|
// func errOneParam(funcName string) error {
|
||||||
return fmt.Errorf("%s() requires exactly one param", funcName)
|
// return fmt.Errorf("%s() requires exactly one param", funcName)
|
||||||
}
|
// }
|
||||||
|
|
||||||
func errMissingRequiredParameter(funcName, paramName string) error {
|
func errMissingRequiredParameter(funcName, paramName string) error {
|
||||||
return fmt.Errorf("%s() missing required parameter %q", funcName, paramName)
|
return fmt.Errorf("%s() missing required parameter %q", funcName, paramName)
|
||||||
|
Loading…
Reference in New Issue
Block a user