com.scalar.db.sql.exception.SqlException Maven / Gradle / Ivy
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);
}
}