/** * Converts SQLiteExceptions into the corresponding * EngineException. */ protected static EngineException convertException(SQLiteException e) { if (e instanceof SQLiteInterruptedException) { return new QueryInterruptedException(e.getMessage()); } else { // Normal db errors: syntax error, database not set errors, etc. // This kind of errors should not retry in replicas. if (e.getErrorCode() == SQLiteConstants.SQLITE_ERROR) { String message = e.getMessage(); if (message != null && message.contains("syntax error]")) { return new SyntaxErrorException(e.getMessage()); } else { return new ShouldNotRetryInReplicaException(e.getMessage()); } } if (e.getErrorCode() == SQLite4JavaClient.ERROR_CODE_MAXIMUM_RESULTS_REACHED) { return new TooManyResultsException(e.getMessage()); } else { // Unexpected exception. Should rety in replica. return new ShouldRetryInReplicaException(e.getMessage(), e); } } } }