Skip to content

Commit

Permalink
Update all RuntimeException
Browse files Browse the repository at this point in the history
  • Loading branch information
psainics committed Jan 15, 2025
1 parent 37e4158 commit 03bb629
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/main/java/io/cdap/plugin/gcp/gcs/StorageClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import io.cdap.cdap.api.exception.ErrorType;
import io.cdap.cdap.api.exception.ErrorUtils;
import io.cdap.plugin.gcp.common.GCPConnectorConfig;
import io.cdap.plugin.gcp.common.GCPErrorDetailsProviderUtil;
import io.cdap.plugin.gcp.common.GCPUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -135,9 +136,11 @@ public void createBucketIfNotExists(GCSPath path, @Nullable String location, @Nu
LOG.warn("Getting 409 Conflict: {} Bucket at destination path {} may already exist.",
e.getMessage(), path.getUri());
} else {
throw new RuntimeException(
String errorReason =
String.format("Unable to create bucket %s. Ensure you entered the correct bucket path and " +
"have permissions for it.", path.getBucket()), e);
"have permissions for it.", path.getBucket());
throw GCPErrorDetailsProviderUtil.getHttpResponseExceptionDetailsFromChain(e, errorReason,
GCPUtils.GCS_SUPPORTED_DOC_URL);
}
}
}
Expand Down Expand Up @@ -220,9 +223,10 @@ private void pairTraverse(GCSPath sourcePath, GCSPath destPath, boolean recursiv
sourceBucket = storage.get(sourcePath.getBucket());
} catch (StorageException e) {
// Add more descriptive error message
throw new RuntimeException(
String.format("Unable to access source bucket %s. ", sourcePath.getBucket())
+ "Ensure you entered the correct bucket path.", e);
String errorReason = String.format("Unable to access destination bucket %s. ", destPath.getBucket()) +
"Ensure you entered the correct bucket path.";
throw GCPErrorDetailsProviderUtil.getHttpResponseExceptionDetailsFromChain(e, errorReason,
GCPUtils.GCS_SUPPORTED_DOC_URL);
}
if (sourceBucket == null) {
String errorReason = String.format("Source bucket '%s' does not exist.", sourcePath.getBucket());
Expand All @@ -234,9 +238,10 @@ private void pairTraverse(GCSPath sourcePath, GCSPath destPath, boolean recursiv
destBucket = storage.get(destPath.getBucket());
} catch (StorageException e) {
// Add more descriptive error message
throw new RuntimeException(
String.format("Unable to access destination bucket %s. ", destPath.getBucket())
+ "Ensure you entered the correct bucket path.", e);
String errorReason = String.format("Unable to access destination bucket %s. ", destPath.getBucket()) +
"Ensure you entered the correct bucket path.";
throw GCPErrorDetailsProviderUtil.getHttpResponseExceptionDetailsFromChain(e, errorReason,
GCPUtils.GCS_SUPPORTED_DOC_URL);
}
if (destBucket == null) {
String errorReason =
Expand Down

0 comments on commit 03bb629

Please sign in to comment.