Send feedback
  
   
 
  
    
      Class SpannerExceptionFactory (6.102.1) 
  
  
  
   
  
    
  
  
    
    
    
    
    
  Version latestkeyboard_arrow_down  
  
 
    
    
    
    
      
  
  
  
    
public   final   class  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 .
Static Methods
   
  asSpannerException(Throwable t) 
  
    
public   static   SpannerException   asSpannerException ( Throwable   t )  
  
  
  
  causeAsRunTimeException(ExecutionException executionException) 
  
    
public   static   RuntimeException   causeAsRunTimeException ( ExecutionException   executionException )  
  
  
  newAbortedDueToConcurrentModificationException(AbortedDueToConcurrentModificationException cause) 
  
    
public   static   AbortedDueToConcurrentModificationException   newAbortedDueToConcurrentModificationException ( AbortedDueToConcurrentModificationException   cause )  
  
  
  
  newAbortedDueToConcurrentModificationException(AbortedException cause) 
  
    
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(AbortedException cause, SpannerException databaseError) 
  
    
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.
newDmlBatchUpdateCountVerificationFailedException(long[] expected, long[] actual) 
  
    
public   static   DmlBatchUpdateCountVerificationFailedException   newDmlBatchUpdateCountVerificationFailedException ( long []   expected ,   long []   actual )  
  Constructs a specific error that
    
      
        Parameters  
      
        Name Description  
      
        expectedlong [] 
      
        actuallong [] 
     
  
  
  newSpannerBatchUpdateException(ErrorCode code, String message, long[] updateCounts) 
  
    
public   static   SpannerBatchUpdateException   newSpannerBatchUpdateException ( ErrorCode   code ,   String   message ,   long []   updateCounts )  
  
  
  newSpannerBatchUpdateException(ErrorCode code, String message, long[] updateCounts, XGoogSpannerRequestId reqId) 
  
    
public   static   SpannerBatchUpdateException   newSpannerBatchUpdateException ( ErrorCode   code ,   String   message ,   long []   updateCounts ,   XGoogSpannerRequestId   reqId )  
  
  
  newSpannerException(ErrorCode code, String message) 
  
    
public   static   SpannerException   newSpannerException ( ErrorCode   code ,   String   message )  
  
  
  newSpannerException(ErrorCode code, String message, XGoogSpannerRequestId reqId) 
  
    
public   static   SpannerException   newSpannerException ( ErrorCode   code ,   String   message ,   XGoogSpannerRequestId   reqId )  
  
  
  newSpannerException(ErrorCode code, String message, Throwable cause) 
  
    
public   static   SpannerException   newSpannerException ( ErrorCode   code ,   String   message ,   Throwable   cause )  
  
  
  newSpannerException(ErrorCode code, String message, Throwable cause, XGoogSpannerRequestId reqId) 
  
    
public   static   SpannerException   newSpannerException ( ErrorCode   code ,   String   message ,   Throwable   cause ,   XGoogSpannerRequestId   reqId )  
  
  
  newSpannerException(Context context, Throwable cause) 
  
    
public   static   SpannerException   newSpannerException ( Context   context ,   Throwable   cause )  
  
    
      
        Parameters  
      
        Name Description  
      
        contextio.grpc.Context  
      
        causeThrowable  
     
  
  
  newSpannerException(Context context, Throwable cause, XGoogSpannerRequestId reqId) 
  
    
public   static   SpannerException   newSpannerException ( Context   context ,   Throwable   cause ,   XGoogSpannerRequestId   reqId )  
  Creates a new exception based on cause. If cause indicates cancellation, 
 context will be inspected to establish the type of cancellation.
 
Intended for internal library use; user code should use #newSpannerException(ErrorCode, String)  instead of this method.
newSpannerException(Throwable cause) 
  
    
public   static   SpannerException   newSpannerException ( Throwable   cause )  
  
  
  
  newSpannerException(Throwable cause, XGoogSpannerRequestId reqId) 
  
    
public   static   SpannerException   newSpannerException ( Throwable   cause ,   XGoogSpannerRequestId   reqId )  
  
  
  propagateInterrupt(InterruptedException e) 
  
    
public   static   SpannerException   propagateInterrupt ( InterruptedException   e )  
  
  
  propagateInterrupt(InterruptedException e, XGoogSpannerRequestId reqId) 
  
    
public   static   SpannerException   propagateInterrupt ( InterruptedException   e ,   XGoogSpannerRequestId   reqId )  
  
  
  propagateTimeout(TimeoutException e) 
  
    
public   static   SpannerException   propagateTimeout ( TimeoutException   e )  
  Transforms a TimeoutException to a SpannerException.
 
 
 try {
   Spanner spanner = SpannerOptions.getDefaultInstance();
   spanner
       .getDatabaseAdminClient()
       .createDatabase("[INSTANCE_ID]", "[DATABASE_ID]", [STATEMENTS])
       .get();
 } catch (TimeoutException e) {
   propagateTimeout(e);
 }
 
  Constructors
   
  SpannerExceptionFactory() 
  
    
public   SpannerExceptionFactory ()  
 
     
    
  
  
  
     
  
    
    
      
       
         
  
  
    
    Send feedback
  
   
 
       
    
    
  
  
 
  Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
  Last updated 2025-10-29 UTC.
 
 
  
  
    
    
    
      
  
  
    Need to tell us more?
  
   
 
     
  
  
    
      [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-10-29 UTC."],[],[]]