All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.scalar.db.sql.exception.SqlException Maven / Gradle / Ivy

There is a newer version: 3.14.0
Show newest version
package com.scalar.db.sql.exception;

import java.util.Optional;
import javax.annotation.Nullable;

/**
 * Base class for all exceptions thrown by the SQL API. Note that, for obvious programming errors,
 * the API might throw JDK runtime exceptions, such as {@link IllegalArgumentException} or {@link
 * IllegalStateException}.
 */
public class SqlException extends RuntimeException {

  @Nullable private final String transactionId;

  public SqlException(String message, @Nullable String transactionId) {
    super(message);
    this.transactionId = transactionId;
  }

  public SqlException(String message, Throwable cause, @Nullable String transactionId) {
    super(message, cause);
    this.transactionId = transactionId;
  }

  /**
   * Returns the transaction ID associated with the transaction that threw the exception.
   *
   * @return the transaction ID associated with the transaction that threw the exception
   */
  public Optional getTransactionId() {
    return Optional.ofNullable(transactionId);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy