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.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.static SpannerBatchUpdateExceptionnewSpannerBatchUpdateException(ErrorCode code, String message, long[] updateCounts) static SpannerExceptionnewSpannerException(ErrorCode code, String message) static SpannerExceptionnewSpannerException(ErrorCode code, String message, Throwable cause) static SpannerExceptionnewSpannerException(io.grpc.Context context, Throwable cause) Creates a new exception based oncause.static SpannerExceptionnewSpannerException(Throwable cause) Creates a new exception based oncause.static SpannerExceptionstatic SpannerExceptionTransforms aTimeoutExceptionto aSpannerException.
-
Constructor Details
-
SpannerExceptionFactory
public SpannerExceptionFactory()
-
-
Method Details
-
newSpannerException
-
newSpannerException
-
propagateInterrupt
-
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. -
newSpannerBatchUpdateException
public static SpannerBatchUpdateException newSpannerBatchUpdateException(ErrorCode code, String message, long[] updateCounts) -
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) 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.
-