`(query driver [])` throws a misleading exception
Closed this issue · 0 comments
Version
1.1.42
Platform
All
Symptom
Executing (query driver [])
results in a clojure.lang.ArityException
with a message that says Wrong number of args (1) passed to: etaoin.api/query
.
Reproduction
See above.
Actual behavior
The exception and error message are misleading because they point to a mismatch between the arguments provided and the arity of the function. The error says that only one argument has been provided, when the user plainly sees two.
Expected behavior
The real error is that the vector argument (the query, q
) is empty. The error message should reflect that.
Diagnosis
When query
detects that q
is a vector, is recursively calls (apply query driver q)
to turn the vector into a variable number of arguments. When Clojure sees that q
is empty, it tries to call (query driver)
, with arity of 1, which query
doesn't support. The code should test whether q
is an empty vector and throw an exception if so.
Action
I'll submit a PR.