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 e42d16dfa3..77e80733d2 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 @@ -153,8 +153,9 @@ protected void executeQueryWithExponentialBackoff(BigQuery bigQuery, try { Failsafe.with(getRetryPolicy()).run(() -> executeQuery(bigQuery, queryConfig, context)); } catch (RuntimeException e) { - LOG.error("Failed to execute BigQuery job. Error: {}", e.getMessage()); - throw new BigQueryJobExecutionException("Failed to execute BigQuery job. Reason: " + e.getMessage()); + String errorMessage = "Failed to execute BigQuery job. Reason: " + e.getMessage(); + LOG.error(errorMessage); + throw new BigQueryJobExecutionException(errorMessage, e); } } @@ -188,7 +189,7 @@ private void executeQuery(BigQuery bigQuery, QueryJobConfiguration queryConfig, } catch (BigQueryException e) { LOG.error("The query job {} failed. Error: {}", jobId.getJob(), e.getMessage()); if (RETRY_ON_REASON.contains(e.getError().getReason())) { - throw new BigQueryJobExecutionException(e.getMessage()); + throw new BigQueryJobExecutionException(e.getMessage(), e); } throw new RuntimeException(e); } diff --git a/src/main/java/io/cdap/plugin/gcp/bigquery/exception/BigQueryJobExecutionException.java b/src/main/java/io/cdap/plugin/gcp/bigquery/exception/BigQueryJobExecutionException.java index 6dadec8955..26861535cf 100644 --- a/src/main/java/io/cdap/plugin/gcp/bigquery/exception/BigQueryJobExecutionException.java +++ b/src/main/java/io/cdap/plugin/gcp/bigquery/exception/BigQueryJobExecutionException.java @@ -30,5 +30,9 @@ public class BigQueryJobExecutionException extends Exception { public BigQueryJobExecutionException(String message) { super(message); } + + public BigQueryJobExecutionException(String message, Throwable cause) { + super(message, cause); + } }