1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00
kyverno/pkg/engine/jmespath/error.go
Charles-Edouard Brétéché 00387f1015
fix: add tests for jp arithmetic funcs (#6240)
* fix: error management in jp functions

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* fix: add tests for jp arithmetic funcs

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

---------

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2023-02-06 15:01:39 +00:00

21 lines
699 B
Go

package jmespath
import (
"fmt"
)
const (
errorPrefix = "JMESPath function '%s': "
invalidArgumentTypeError = errorPrefix + "%d argument is expected of %s type"
genericError = errorPrefix + "%s"
argOutOfBoundsError = errorPrefix + "%d argument is out of bounds (%d)"
zeroDivisionError = errorPrefix + "Zero divisor passed"
nonIntModuloError = errorPrefix + "Non-integer argument(s) passed for modulo"
typeMismatchError = errorPrefix + "Types mismatch"
)
func formatError(format string, function string, values ...interface{}) error {
args := []interface{}{function}
args = append(args, values...)
return fmt.Errorf(format, args...)
}