Package com.google.cloud.spanner
Class SpannerExceptionFactory
java.lang.Object
com.google.cloud.spanner.SpannerExceptionFactory
A factory for creating instances of
SpannerException and its subtypes. All creation of
these exceptions is directed through the factory. This ensures that particular types of errors
are always expressed as the same concrete exception type. For example, exceptions of type ErrorCode.ABORTED are always represented by AbortedException.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SpannerExceptionConverts the givenThrowableto aSpannerException.static RuntimeExceptioncauseAsRunTimeException(ExecutionException executionException) Constructs a newAbortedDueToConcurrentModificationExceptionthat can be re-thrown for a transaction that had already been aborted, but that the client application tried to use for additional statements.Constructs a specific aborted exception that should only be thrown by a connection after an internal retry aborted due to concurrent modifications.newAbortedDueToConcurrentModificationException(AbortedException cause, SpannerException databaseError) Constructs a specific aborted exception that should only be thrown by a connection after an internal retry aborted because a database call caused an exception that did not happen during the original attempt.newDmlBatchUpdateCountVerificationFailedException(long[] expected, long[] actual) Constructs a specific error thatstatic SpannerBatchUpdateExceptionnewSpannerBatchUpdateException(ErrorCode code, String message, long[] updateCounts) static SpannerBatchUpdateExceptionnewSpannerBatchUpdateException(ErrorCode code, String message, long[] updateCounts, XGoogSpannerRequestId reqId) static SpannerExceptionnewSpannerException(ErrorCode code, String message) static SpannerExceptionnewSpannerException(ErrorCode code, String message, XGoogSpannerRequestId reqId) static SpannerExceptionnewSpannerException(ErrorCode code, String message, Throwable cause) static SpannerExceptionnewSpannerException(ErrorCode code, String message, Throwable cause, XGoogSpannerRequestId reqId) static SpannerExceptionnewSpannerException(io.grpc.Context context, Throwable cause) static SpannerExceptionnewSpannerException(io.grpc.Context context, Throwable cause, XGoogSpannerRequestId reqId) Creates a new exception based oncause.static SpannerExceptionnewSpannerException(Throwable cause) Creates a new exception based oncause.static SpannerExceptionnewSpannerException(Throwable cause, XGoogSpannerRequestId reqId) static SpannerExceptionstatic SpannerExceptionstatic SpannerExceptionTransforms aTimeoutExceptionto aSpannerException.
-
Constructor Details
-
SpannerExceptionFactory
public SpannerExceptionFactory()
-
-
Method Details
-
newSpannerException
-
newSpannerException
public static SpannerException newSpannerException(ErrorCode code, @Nullable String message, @Nullable Throwable cause, @Nullable XGoogSpannerRequestId reqId) -
newSpannerException
public static SpannerException newSpannerException(ErrorCode code, @Nullable String message, @Nullable XGoogSpannerRequestId reqId) -
newSpannerException
-
propagateInterrupt
-
propagateInterrupt
public static SpannerException propagateInterrupt(InterruptedException e, XGoogSpannerRequestId reqId) -
propagateTimeout
Transforms aTimeoutExceptionto aSpannerException.try { Spanner spanner = SpannerOptions.getDefaultInstance(); spanner .getDatabaseAdminClient() .createDatabase("[INSTANCE_ID]", "[DATABASE_ID]", [STATEMENTS]) .get(); } catch (TimeoutException e) { propagateTimeout(e); } -
asSpannerException
Converts the givenThrowableto aSpannerException. Iftis already a (subclass of a)SpannerException,tis returned unaltered. Otherwise, a newSpannerExceptionis created withtas its cause. -
newSpannerException
Creates a new exception based oncause.Intended for internal library use; user code should use
newSpannerException(ErrorCode, String)instead of this method. -
newSpannerException
-
newSpannerBatchUpdateException
public static SpannerBatchUpdateException newSpannerBatchUpdateException(ErrorCode code, String message, long[] updateCounts) -
newSpannerBatchUpdateException
public static SpannerBatchUpdateException newSpannerBatchUpdateException(ErrorCode code, String message, long[] updateCounts, @Nullable XGoogSpannerRequestId reqId) -
newDmlBatchUpdateCountVerificationFailedException
public static DmlBatchUpdateCountVerificationFailedException newDmlBatchUpdateCountVerificationFailedException(long[] expected, long[] actual) Constructs a specific error that -
newAbortedDueToConcurrentModificationException
public static AbortedDueToConcurrentModificationException newAbortedDueToConcurrentModificationException(AbortedException cause) Constructs a specific aborted exception that should only be thrown by a connection after an internal retry aborted due to concurrent modifications. -
newAbortedDueToConcurrentModificationException
public static AbortedDueToConcurrentModificationException newAbortedDueToConcurrentModificationException(AbortedException cause, SpannerException databaseError) Constructs a specific aborted exception that should only be thrown by a connection after an internal retry aborted because a database call caused an exception that did not happen during the original attempt. -
newAbortedDueToConcurrentModificationException
public static AbortedDueToConcurrentModificationException newAbortedDueToConcurrentModificationException(AbortedDueToConcurrentModificationException cause) Constructs a newAbortedDueToConcurrentModificationExceptionthat can be re-thrown for a transaction that had already been aborted, but that the client application tried to use for additional statements. -
newSpannerException
public static SpannerException newSpannerException(@Nullable io.grpc.Context context, Throwable cause) -
newSpannerException
public static SpannerException newSpannerException(@Nullable io.grpc.Context context, Throwable cause, @Nullable XGoogSpannerRequestId reqId) Creates a new exception based oncause. Ifcauseindicates cancellation,contextwill be inspected to establish the type of cancellation.Intended for internal library use; user code should use
newSpannerException(ErrorCode, String)instead of this method. -
causeAsRunTimeException
-