longevityframework / longevity

A Persistence Framework for Scala and NoSQL
http://longevityframework.org
Other
102 stars 6 forks source link

improve error message for query failures #19

Open sullivan- opened 7 years ago

sullivan- commented 7 years ago

in both Cassandra and SQLite back ends, when the user constructs a query that mentions a property that is not in a key or index, the query fails at runtime. For Cassandra, it fails like this:

com.datastax.driver.core.exceptions.InvalidQueryException: Undefined name prop_char in where clause ('prop_char <= ?')

For SQLite, it fails like this:

Cause: org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (no such column: prop_char)

Ideally, we would catch these at compile time. But that seems to be very difficult. Second best would be to catch these errors before the query runs, and throw a longevity exception instead. Satisfactory would be to catch these kinds of errors when they are thrown, and rethrow a longevity exception. But we would have to be careful not to catch exceptions that have other causes than the one we are looking to catch.

Note migration to shapeless would probably allow for catching these at compile time. https://www.pivotaltracker.com/story/show/140864207

sullivan- commented 7 years ago

this is tracked on my story board here: https://www.pivotaltracker.com/story/show/137721427