From 577e732741d147f1164546ce450d603a0d65e7fd Mon Sep 17 00:00:00 2001 From: Jan Duzinkiewicz Date: Fri, 5 Apr 2024 13:35:23 -0700 Subject: [PATCH] narrowing down aws sdk exception types that hard stop a build so that it can function offline --- .../androidx/build/gradle/s3buildcache/S3StorageService.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/s3buildcache/src/main/kotlin/androidx/build/gradle/s3buildcache/S3StorageService.kt b/s3buildcache/src/main/kotlin/androidx/build/gradle/s3buildcache/S3StorageService.kt index 9185c2e..21354f6 100644 --- a/s3buildcache/src/main/kotlin/androidx/build/gradle/s3buildcache/S3StorageService.kt +++ b/s3buildcache/src/main/kotlin/androidx/build/gradle/s3buildcache/S3StorageService.kt @@ -21,7 +21,9 @@ import androidx.build.gradle.core.FileHandleInputStream import androidx.build.gradle.core.FileHandleInputStream.Companion.handleInputStream import androidx.build.gradle.core.StorageService import org.gradle.api.logging.Logging +import software.amazon.awssdk.core.exception.SdkClientException import software.amazon.awssdk.core.exception.SdkException +import software.amazon.awssdk.core.exception.SdkServiceException import software.amazon.awssdk.core.sync.RequestBody import software.amazon.awssdk.services.s3.S3Client import software.amazon.awssdk.services.s3.model.DeleteObjectRequest @@ -110,8 +112,8 @@ class S3StorageService( client.headBucket(HeadBucketRequest.builder().bucket(bucketName).build()) } catch(e: NoSuchBucketException) { throw Exception("Bucket $bucketName in $region cannot be found: ${e.message}") - } catch (e: SdkException ) { - throw Exception("AWS SDK exception on validating access to $bucketName in $region: ${e.message}") + } catch (e: SdkServiceException ) { + throw Exception("AWS SDK exception on validating access to $bucketName in $region: ${e::class.simpleName} - ${e.message}") } catch (e: Exception) { logger.warn("Couldn't validate S3 client config: ${e.message}")