mozilla / mentat

UNMAINTAINED A persistent, relational store inspired by Datomic and DataScript.
https://mozilla.github.io/mentat/
Apache License 2.0
1.65k stars 115 forks source link

Add Exception throwing to Android SDK when an error is returned from FFI #700

Open fluffyemily opened 6 years ago

fluffyemily commented 6 years ago

Currently, if we receive an error from the FFI inside the Android SDK, we simply print the error and continue. We should throw an exception instead.

This ticket involves - creating set of Mentat specific Exception classes and throwing them when an error is received from Mentat over the FFI.

ncalexan commented 6 years ago

So I definitely agree we should be exposing Mentat errors as Exception instances to Java, but I'd like to pump the brakes a little bit on the "set of Mentat specific Exception classes". The errors coming out of Mentat are fluctuating wildly -- for example, 1/2 of the transactor errors are just strings -- so let's not tie ourselves to any one representation too soon. Could we do the simplest thing first -- a MentatException with a string description -- and then figure out what value we're really trying to provide before we encode a class hierarchy?

rnewman commented 6 years ago

Something I've used before and think might be valuable here: some errors are recoverable and some are not, and some are external and some caused by your code.

An error during a query might be:

At the very least, then, I think it's worth making parse errors — EDN, query, transact — separate and visible to the developer. The rest can be bucketed as "DB error".

fluffyemily commented 6 years ago

The three error types we have on iOS right now are:

public enum QueryError: Error {
    case invalidKeyword(message: String)
    case executionFailed(message: String)
}

public struct MentatError: Error {
    let message: String
}

public enum PointerError: Error {
    case pointerConsumed
}

Adding TransactError and ParseError to this set is easy enough I think. This is the set I was going to replicate in the Java library.