Skip to content

Commit

Permalink
Throw a more accurate exception when query vector is empty (#664)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgr authored Sep 14, 2024
1 parent 5820ec6 commit ea9910e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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-<xyz>-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])

Expand Down
6 changes: 5 additions & 1 deletion src/etaoin/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit ea9910e

Please sign in to comment.