From ecff60646d128a5c1fa355a8bb85541c40d01dd7 Mon Sep 17 00:00:00 2001 From: Jay Pipes Date: Thu, 9 Oct 2025 12:27:58 -0400 Subject: [PATCH] add runtime error for failure to find var path JSONPathVarFromNotMatched returns a RuntimeError indicating that a variable could not be populated due to a failure to match the variable's from JSONPath to expected output. This is a RuntimeError because subsequent test specifications may depend on the variable having been populated. Signed-off-by: Jay Pipes --- api/error.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/api/error.go b/api/error.go index 7bd9c17..11e7c83 100644 --- a/api/error.go +++ b/api/error.go @@ -133,6 +133,15 @@ var ( "%w: timeout conflict", RuntimeError, ) + // ErrJSONPathVarFromNotMatched is returned when the `var.$VAR.from` + // JSONPath expression fails to match some output results. This is a + // runtime error because we cannot continue execution after failing to + // populate the value of a variable that subsequent test specifications may + // depend on. + ErrJSONPathVarFromNotMatched = fmt.Errorf( + "%w: var.from JSONPath not matched", + RuntimeError, + ) ) // DependencyNotSatified returns an ErrDependencyNotSatisfied with the supplied @@ -193,3 +202,18 @@ func TimeoutConflict( } return fmt.Errorf("%w: %s", ErrTimeoutConflict, msg) } + +// JSONPathVarFromNotMatched returns a RuntimeError indicating that a variable +// could not be populated due to a failure to match the variable's from +// JSONPath to expected output. This is a RuntimeError because subsequent test +// specifications may depend on the variable having been populated. +func JSONPathVarFromNotMatched( + varName string, + path string, +) error { + return fmt.Errorf( + "%w: variable %s could not be filled because "+ + "JSONPath expression %s did not match output", + ErrJSONPathVarFromNotMatched, varName, path, + ) +}