Open fluffyemily opened 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?
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".
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.
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.