From e96607ad6613b17bb96d621ff6db3ccf62e943be Mon Sep 17 00:00:00 2001 From: Dave Roberts Date: Sat, 14 Sep 2024 14:44:28 -0500 Subject: [PATCH] Throw a more accurate exception when query vector is empty --- CHANGELOG.adoc | 1 + src/etaoin/api.clj | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 14fe52a..6beef14 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -31,6 +31,7 @@ A release with an intentional breaking changes is marked with: ** {issue}649[#649]: When supplied a vector argument for `q-text`, `fill-multi` and `fill-human-multi` now fill fields in the order that fields appear in the vector. Previously, the order was not guaranteed. ({person}dgr[@dgr]) ** {issue}657[#657]: Make `set--timeout` functions resilient to reasonable non-integer timeouts (e.g., rationals, doubles, etc.). ({person}dgr[@dgr]) ** {issue}661[#661]: Fix `:fn/enabled`. ({person}dgr[@dgr]) +** {issue}663[#663]: `query` throws a more accurate exception with a more accurate error message when provided with an empty query vector. ({person}dgr[@dgr]) * Docs ** {issue}656[#656]: Correctly describe behavior when query's parameter is a string. The User Guide and `query` doc strings say that a string passed to `query` is interpreted as an XPath expression. In fact, `query` interprets this as either XPath or CSS depending on the setting of the driver's `:locator` parameter, which can be changed. ({person}dgr[@dgr]) diff --git a/src/etaoin/api.clj b/src/etaoin/api.clj index e2f863c..16af594 100644 --- a/src/etaoin/api.clj +++ b/src/etaoin/api.clj @@ -636,7 +636,11 @@ (get-active-element driver) (vector? q) - (apply query driver q) + (if (empty? q) + (throw+ {:type :etaoin/argument + :message "Vector query must be non-empty" + :q q}) + (apply query driver q)) :else (let [[loc term] (query/expand driver q)]