static BaseServiceException translateAndThrow(ExecutionException ex) { BaseServiceException.translate(ex); throw new ComputeException(UNKNOWN_CODE, ex.getMessage(), ex.getCause()); } }
static BaseServiceException translateAndThrow(ExecutionException ex) { BaseServiceException.translate(ex); throw new BigQueryException(UNKNOWN_CODE, ex.getMessage(), ex.getCause()); } }
/** * Translate RetryHelperException to the TranslateException that caused the error. This method * will always throw an exception. * * @throws TranslateException when {@code ex} was caused by a {@code TranslateException} */ static BaseServiceException translateAndThrow(RetryHelperException ex) { BaseServiceException.translate(ex); throw new TranslateException(UNKNOWN_CODE, ex.getMessage(), ex.getCause()); } }
/** * Translate RetryHelperException to the ComputeException that caused the error. This method will * always throw an exception. * * @throws ComputeException when {@code ex} was caused by a {@code ComputeException} */ static BaseServiceException translateAndThrow(RetryHelperException ex) { BaseServiceException.translate(ex); throw new ComputeException(UNKNOWN_CODE, ex.getMessage(), ex.getCause()); }
/** * Translate RetryHelperException to the BigQueryException that caused the error. This method will * always throw an exception. * * @throws BigQueryException when {@code ex} was caused by a {@code BigQueryException} */ static BaseServiceException translateAndThrow(RetryHelperException ex) { BaseServiceException.translate(ex); throw new BigQueryException(UNKNOWN_CODE, ex.getMessage(), ex.getCause()); }
/** * Translate RetryHelperException to the DnsException that caused the error. This method will * always throw an exception. * * @throws DnsException when {@code ex} was caused by a {@code DnsException} */ static DnsException translateAndThrow(RetryHelperException ex) { BaseServiceException.translate(ex); throw new DnsException(UNKNOWN_CODE, ex.getMessage(), ex.getCause()); } }
/** * Translate RetryHelperException to the DatastoreException that caused the error. This method * will always throw an exception. * * @throws DatastoreException when {@code ex} was caused by a {@code DatastoreException} */ static DatastoreException translateAndThrow(RetryHelperException ex) { BaseServiceException.translate(ex); throw new DatastoreException(UNKNOWN_CODE, ex.getMessage(), null, ex.getCause()); }
/** * Translate RetryHelperException to the ResourceManagerException that caused the error. This * method will always throw an exception. * * @throws ResourceManagerException when {@code ex} was caused by a {@code * ResourceManagerException} */ static ResourceManagerException translateAndThrow(RetryHelperException ex) { BaseServiceException.translate(ex); throw new ResourceManagerException(UNKNOWN_CODE, ex.getMessage(), ex.getCause()); } }
/** * Translate RetryHelperException to the StorageException that caused the error. This method will * always throw an exception. * * @throws StorageException when {@code ex} was caused by a {@code StorageException} */ public static StorageException translateAndThrow(RetryHelperException ex) { BaseServiceException.translate(ex); throw new StorageException(UNKNOWN_CODE, ex.getMessage(), ex.getCause()); } }
@Test public void testTranslateAndThrow() throws Exception { IOException exception = new SocketTimeoutException(); BaseGrpcServiceException cause = new BaseGrpcServiceException(exception, IDEMPOTENT); RetryHelper.RetryHelperException exceptionMock = createMock(RetryHelper.RetryHelperException.class); expect(exceptionMock.getCause()).andReturn(cause).times(2); replay(exceptionMock); try { BaseServiceException.translate(exceptionMock); } catch (BaseServiceException ex) { assertEquals(0, ex.getCode()); assertNull(ex.getMessage()); assertTrue(ex.isRetryable()); } finally { verify(exceptionMock); } } }
@Test public void testTranslateAndThrow() throws Exception { BaseServiceException cause = new BaseHttpServiceException(CODE, MESSAGE, REASON, IDEMPOTENT, EMPTY_RETRYABLE_ERRORS); RetryHelper.RetryHelperException exceptionMock = createMock(RetryHelper.RetryHelperException.class); expect(exceptionMock.getCause()).andReturn(cause).times(2); replay(exceptionMock); try { BaseServiceException.translate(exceptionMock); } catch (BaseServiceException ex) { assertEquals(CODE, ex.getCode()); assertEquals(MESSAGE, ex.getMessage()); assertFalse(ex.isRetryable()); } finally { verify(exceptionMock); } } }
@Test public void testTranslateAndThrow() throws Exception { BaseServiceException cause = new BaseServiceException(ExceptionData.from(CODE, MESSAGE, REASON, NOT_RETRYABLE)); RetryHelper.RetryHelperException exceptionMock = createMock(RetryHelper.RetryHelperException.class); expect(exceptionMock.getCause()).andReturn(cause).times(2); replay(exceptionMock); try { BaseServiceException.translate(exceptionMock); } catch (BaseServiceException ex) { assertEquals(CODE, ex.getCode()); assertEquals(MESSAGE, ex.getMessage()); assertFalse(ex.isRetryable()); } finally { verify(exceptionMock); } }
static BaseServiceException translateAndThrow(ExecutionException ex) { BaseServiceException.translate(ex); throw new BigQueryException(UNKNOWN_CODE, ex.getMessage(), ex.getCause()); } }
/** * Translate RetryHelperException to the TranslateException that caused the error. This method * will always throw an exception. * * @throws TranslateException when {@code ex} was caused by a {@code TranslateException} */ static BaseServiceException translateAndThrow(RetryHelperException ex) { BaseServiceException.translate(ex); throw new TranslateException(UNKNOWN_CODE, ex.getMessage(), ex.getCause()); } }
/** * Translate RetryHelperException to the StorageException that caused the error. This method will * always throw an exception. * * @throws StorageException when {@code ex} was caused by a {@code StorageException} */ public static StorageException translateAndThrow(RetryHelperException ex) { BaseServiceException.translate(ex); throw new StorageException(UNKNOWN_CODE, ex.getMessage(), ex.getCause()); } }
/** * Translate RetryHelperException to the BigQueryException that caused the error. This method will * always throw an exception. * * @throws BigQueryException when {@code ex} was caused by a {@code BigQueryException} */ static BaseServiceException translateAndThrow(RetryHelperException ex) { BaseServiceException.translate(ex); throw new BigQueryException(UNKNOWN_CODE, ex.getMessage(), ex.getCause()); }
/** * Translate RetryHelperException to the DatastoreException that caused the error. This method * will always throw an exception. * * @throws DatastoreException when {@code ex} was caused by a {@code DatastoreException} */ static DatastoreException translateAndThrow(RetryHelperException ex) { BaseServiceException.translate(ex); throw new DatastoreException(UNKNOWN_CODE, ex.getMessage(), null, ex.getCause()); }