Skip to content

Commit

Permalink
Merge pull request #1518 from data-integrations/PLUGIN-1842
Browse files Browse the repository at this point in the history
[PLUGIN-1842] Fix error type in GCS Bucket Create
  • Loading branch information
itsankit-google authored Feb 18, 2025
2 parents 41a9e15 + 9ef260b commit 3b2036c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Throwable> causalChain = Throwables.getCausalChain(e);
for (Throwable t : causalChain) {
Expand Down
19 changes: 13 additions & 6 deletions src/main/java/io/cdap/plugin/gcp/gcs/actions/GCSBucketCreate.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 3b2036c

Please sign in to comment.