From 9ef260bb9103b4e8a40d0d77ba381c78f6816553 Mon Sep 17 00:00:00 2001 From: itsankit-google Date: Tue, 18 Feb 2025 18:02:47 +0000 Subject: [PATCH] Fix error type in GCS Bucket Create --- .../gcp/common/GCPErrorDetailsProvider.java | 1 + .../gcp/gcs/actions/GCSBucketCreate.java | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/cdap/plugin/gcp/common/GCPErrorDetailsProvider.java b/src/main/java/io/cdap/plugin/gcp/common/GCPErrorDetailsProvider.java index 67d28bda9..547815a23 100644 --- a/src/main/java/io/cdap/plugin/gcp/common/GCPErrorDetailsProvider.java +++ b/src/main/java/io/cdap/plugin/gcp/common/GCPErrorDetailsProvider.java @@ -41,6 +41,7 @@ public class GCPErrorDetailsProvider implements ErrorDetailsProvider { * @param e The Throwable to get the error information from. * @return A ProgramFailureException with the given error information, otherwise null. */ + @Override public ProgramFailureException getExceptionDetails(Exception e, ErrorContext errorContext) { List causalChain = Throwables.getCausalChain(e); for (Throwable t : causalChain) { diff --git a/src/main/java/io/cdap/plugin/gcp/gcs/actions/GCSBucketCreate.java b/src/main/java/io/cdap/plugin/gcp/gcs/actions/GCSBucketCreate.java index 7882445ac..891080afa 100644 --- a/src/main/java/io/cdap/plugin/gcp/gcs/actions/GCSBucketCreate.java +++ b/src/main/java/io/cdap/plugin/gcp/gcs/actions/GCSBucketCreate.java @@ -25,6 +25,7 @@ import io.cdap.cdap.api.annotation.Name; import io.cdap.cdap.api.annotation.Plugin; import io.cdap.cdap.api.exception.ErrorCategory; +import io.cdap.cdap.api.exception.ErrorCodeType; import io.cdap.cdap.api.exception.ErrorType; import io.cdap.cdap.api.exception.ErrorUtils; import io.cdap.cdap.etl.api.FailureCollector; @@ -141,9 +142,12 @@ public void run(ActionContext context) throws Exception { } else if (gcsPath.equals(bucketPath) && config.failIfExists()) { // if the gcs path is just a bucket, and it exists, fail the pipeline rollback = true; - String errorReason = String.format("Path %s already exists", gcsPath); - throw ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN), - errorReason, errorReason, ErrorType.USER, true, null); + String errorReason = String.format("Path %s already exists. " + + "Please delete the existing path or set 'Fail if Object Exists' to false.", + gcsPath); + throw ErrorUtils.getProgramFailureException( + new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN), + errorReason, errorReason, ErrorType.USER, true, null); } } @@ -171,9 +175,12 @@ public void run(ActionContext context) throws Exception { } else { if (config.failIfExists()) { rollback = true; - String errorReason = String.format("Path %s already exists", gcsPath); - throw ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN), - errorReason, errorReason, ErrorType.SYSTEM, true, null); + String errorReason = String.format("Path %s already exists. " + + "Please delete the existing path or set 'Fail if Object Exists' to false.", + gcsPath); + throw ErrorUtils.getProgramFailureException( + new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN), + errorReason, errorReason, ErrorType.USER, false, null); } } }