You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In TypeDB 3.0 drivers, the Java transaction.query() API returns a Promise<QueryAnswer>. However, we know that sometimes, there can be parsing errors, compile errors, etc. that arise before iterating the answers.
In Rust, this same function has the following signature: async Transaction::query(...) -> Result<QueryAnswer>, which indicates that once the .query() is awaited, the result must be inspected. In Java, the way to enforce this is to use a Checked exception:
var promise = transaction.query(...);
promise.resolve(); // should require the user to wrap in a try..catch
Proposed Solution
We should introduce two types of Promise in Java - CheckedPromise, and Promise. When we know the promise-based operation can fail, we should enforce the user catches it by returning a CheckedPromise. Otherwise, it should be an Promise that cannot will not fail (or only throw Runtime exceptions).
The text was updated successfully, but these errors were encountered:
Problem to Solve
In TypeDB 3.0 drivers, the Java
transaction.query()
API returns aPromise<QueryAnswer>
. However, we know that sometimes, there can be parsing errors, compile errors, etc. that arise before iterating the answers.In Rust, this same function has the following signature:
async Transaction::query(...) -> Result<QueryAnswer>
, which indicates that once the.query()
isawait
ed, the result must be inspected. In Java, the way to enforce this is to use a Checked exception:Proposed Solution
We should introduce two types of
Promise
in Java -CheckedPromise
, andPromise
. When we know the promise-based operation can fail, we should enforce the user catches it by returning aCheckedPromise
. Otherwise, it should be anPromise
that cannot will not fail (or only throw Runtime exceptions).The text was updated successfully, but these errors were encountered: