From e0c7a9b2250b6c1a1a7da55917a11cc96d4c5d2a Mon Sep 17 00:00:00 2001 From: AMit-Cloudsufi Date: Tue, 21 Jan 2025 12:07:11 +0000 Subject: [PATCH] update --- .../gcp/bigquery/action/BigQueryExecute.java | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/main/java/io/cdap/plugin/gcp/bigquery/action/BigQueryExecute.java b/src/main/java/io/cdap/plugin/gcp/bigquery/action/BigQueryExecute.java index 7070b5186..8a0e89a88 100644 --- a/src/main/java/io/cdap/plugin/gcp/bigquery/action/BigQueryExecute.java +++ b/src/main/java/io/cdap/plugin/gcp/bigquery/action/BigQueryExecute.java @@ -156,11 +156,11 @@ public void run(ActionContext context) throws Exception { if (config.getRetryOnBackendError()) { try { executeQueryWithExponentialBackoff(bigQuery, queryConfig, context); - } catch (Exception e) { + } catch (Throwable e) { String error = String.format( "Failed to execute query with exponential backoff with message: %s", e.getMessage()); - throw GCPErrorDetailsProviderUtil.getHttpResponseExceptionDetailsFromChain(e, error, ErrorType.USER, - true, GCPUtils.BQ_SUPPORTED_DOC_URL); + throw GCPErrorDetailsProviderUtil.getHttpResponseExceptionDetailsFromChain(new RuntimeException(e), error, + ErrorType.USER, true, GCPUtils.BQ_SUPPORTED_DOC_URL); } } else { executeQuery(bigQuery, queryConfig, context); @@ -168,20 +168,14 @@ public void run(ActionContext context) throws Exception { } void executeQueryWithExponentialBackoff(BigQuery bigQuery, - QueryJobConfiguration queryConfig, ActionContext context) { + QueryJobConfiguration queryConfig, ActionContext context) throws Throwable { try { Failsafe.with(getRetryPolicy()).run(() -> executeQuery(bigQuery, queryConfig, context)); } catch (FailsafeException e) { if (e.getCause() != null) { - String error = String.format( - "Failed to execute query with exponential backoff with cause: %s.", e.getCause()); - throw ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN), - error, error, ErrorType.USER, false, e); + throw e.getCause(); } - String error = String.format( - "Failed to execute query with exponential backoff with message: %s.", e.getMessage()); - throw GCPErrorDetailsProviderUtil.getHttpResponseExceptionDetailsFromChain(e, error, ErrorType.USER, - true, GCPUtils.BQ_SUPPORTED_DOC_URL); + throw e; } } @@ -214,7 +208,7 @@ private void executeQuery(BigQuery bigQuery, QueryJobConfiguration queryConfig, } catch (BigQueryException e) { LOG.error("The query job {} failed. Error: {}", jobId.getJob(), e.getError().getMessage()); if (RETRY_ON_REASON.contains(e.getError().getReason())) { - throw new BigQueryJobExecutionException(e.getError().getMessage()); + throw new BigQueryJobExecutionException(e.getError().getMessage(), e); } String error = String.format("Failed to execute query with message: %s", e.getMessage()); throw GCPErrorDetailsProviderUtil.getHttpResponseExceptionDetailsFromChain(e, error, ErrorType.UNKNOWN,