Skip to content

Commit ea9910e

Browse files
authored
Throw a more accurate exception when query vector is empty (#664)
1 parent 5820ec6 commit ea9910e

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.adoc

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ A release with an intentional breaking changes is marked with:
3131
** {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])
3232
** {issue}657[#657]: Make `set-<xyz>-timeout` functions resilient to reasonable non-integer timeouts (e.g., rationals, doubles, etc.). ({person}dgr[@dgr])
3333
** {issue}661[#661]: Fix `:fn/enabled`. ({person}dgr[@dgr])
34+
** {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])
3435
* Docs
3536
** {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])
3637

src/etaoin/api.clj

+5-1
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,11 @@
636636
(get-active-element driver)
637637

638638
(vector? q)
639-
(apply query driver q)
639+
(if (empty? q)
640+
(throw+ {:type :etaoin/argument
641+
:message "Vector query must be non-empty"
642+
:q q})
643+
(apply query driver q))
640644

641645
:else
642646
(let [[loc term] (query/expand driver q)]

0 commit comments

Comments
 (0)