public void onException(Exception e, OperationType operationType) {

    // Record errors.
    if (operationType == OperationType.Write) {
      metrics.writeFailureCount.inc();
    } else if (operationType == OperationType.Read) {
      metrics.readFailureCount.inc();
    } else if (operationType == OperationType.Copy) {
      metrics.copyFailureCount.inc();
    } else if (operationType == OperationType.BatchUpdate) {
      metrics.batchUpdateFailureCount.inc();
    } else if (operationType == OperationType.Delete) {
      metrics.deleteFailureCount.inc();
    }

    // Close connection for all non transient sql exceptions.
    if (!(e instanceof SQLNonTransientException || (e instanceof BatchUpdateException
        && e.getCause() instanceof SQLNonTransientException))) {
      closeActiveConnection();
    }
  }
Handle a SQL exception on a database operation.
@param e the {@link SQLException} encountered.
@param operationType type of mysql operation
ambry-mysql/src/main/java/com/github/ambry/mysql/MySqlDataAccessor.java