Skip to content

Commit 2467c7b

Browse files
Merge pull request #1519 from data-integrations/PLUGIN-1842-cherrypick
[🍒][PLUGIN-1842] Fix error type in GCS Bucket Create
2 parents db1302e + 79c6c6d commit 2467c7b

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/main/java/io/cdap/plugin/gcp/common/GCPErrorDetailsProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class GCPErrorDetailsProvider implements ErrorDetailsProvider {
4141
* @param e The Throwable to get the error information from.
4242
* @return A ProgramFailureException with the given error information, otherwise null.
4343
*/
44+
@Override
4445
public ProgramFailureException getExceptionDetails(Exception e, ErrorContext errorContext) {
4546
List<Throwable> causalChain = Throwables.getCausalChain(e);
4647
for (Throwable t : causalChain) {

src/main/java/io/cdap/plugin/gcp/gcs/actions/GCSBucketCreate.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import io.cdap.cdap.api.annotation.Name;
2626
import io.cdap.cdap.api.annotation.Plugin;
2727
import io.cdap.cdap.api.exception.ErrorCategory;
28+
import io.cdap.cdap.api.exception.ErrorCodeType;
2829
import io.cdap.cdap.api.exception.ErrorType;
2930
import io.cdap.cdap.api.exception.ErrorUtils;
3031
import io.cdap.cdap.etl.api.FailureCollector;
@@ -141,9 +142,12 @@ public void run(ActionContext context) throws Exception {
141142
} else if (gcsPath.equals(bucketPath) && config.failIfExists()) {
142143
// if the gcs path is just a bucket, and it exists, fail the pipeline
143144
rollback = true;
144-
String errorReason = String.format("Path %s already exists", gcsPath);
145-
throw ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN),
146-
errorReason, errorReason, ErrorType.USER, true, null);
145+
String errorReason = String.format("Path %s already exists. "
146+
+ "Please delete the existing path or set 'Fail if Object Exists' to false.",
147+
gcsPath);
148+
throw ErrorUtils.getProgramFailureException(
149+
new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN),
150+
errorReason, errorReason, ErrorType.USER, true, null);
147151
}
148152
}
149153

@@ -171,9 +175,12 @@ public void run(ActionContext context) throws Exception {
171175
} else {
172176
if (config.failIfExists()) {
173177
rollback = true;
174-
String errorReason = String.format("Path %s already exists", gcsPath);
175-
throw ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN),
176-
errorReason, errorReason, ErrorType.SYSTEM, true, null);
178+
String errorReason = String.format("Path %s already exists. "
179+
+ "Please delete the existing path or set 'Fail if Object Exists' to false.",
180+
gcsPath);
181+
throw ErrorUtils.getProgramFailureException(
182+
new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN),
183+
errorReason, errorReason, ErrorType.USER, false, null);
177184
}
178185
}
179186
}

0 commit comments

Comments
 (0)