File tree 1 file changed +8
-2
lines changed
samples/snippets/src/test/java/com/example/spanner
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 19
19
import static com .google .common .truth .Truth .assertThat ;
20
20
import static org .junit .Assert .assertTrue ;
21
21
22
+ import com .google .api .gax .rpc .FailedPreconditionException ;
22
23
import com .google .cloud .Timestamp ;
23
24
import com .google .cloud .spanner .DatabaseId ;
24
25
import com .google .cloud .spanner .ErrorCode ;
@@ -643,8 +644,13 @@ private static void deleteAllBackups(String instanceId) throws InterruptedExcept
643
644
attempts ++;
644
645
databaseAdminClient .deleteBackup (backup .getName ());
645
646
break ;
646
- } catch (SpannerException e ) {
647
- if (e .getErrorCode () == ErrorCode .FAILED_PRECONDITION
647
+ } catch (SpannerException | FailedPreconditionException e ) {
648
+ ErrorCode errorCode = ErrorCode .FAILED_PRECONDITION ;
649
+
650
+ if (e instanceof SpannerException ) {
651
+ errorCode = ((SpannerException ) e ).getErrorCode ();
652
+ }
653
+ if (errorCode == ErrorCode .FAILED_PRECONDITION
648
654
&& e .getMessage ()
649
655
.contains (
650
656
"Please try deleting the backup once the restore or post-restore optimize "
You can’t perform that action at this time.
0 commit comments