Skip to content

Commit

Permalink
IOException wraps StorageException wraps GoogleJsonResponseException
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan King committed Jan 20, 2023
1 parent f56a819 commit ff1bb1a
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions hail/src/main/scala/is/hail/io/fs/GoogleStorageFS.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package is.hail.io.fs


import java.io.{ByteArrayInputStream, FileNotFoundException}
import java.io.{ByteArrayInputStream, FileNotFoundException, IOException}
import java.net.URI
import java.nio.ByteBuffer
import java.nio.file.FileSystems
Expand All @@ -10,7 +10,6 @@ import com.google.auth.oauth2.ServiceAccountCredentials
import com.google.cloud.{ReadChannel, WriteChannel}
import com.google.cloud.storage.Storage.{BlobListOption, BlobWriteOption, BlobSourceOption}
import com.google.cloud.storage.{Option => StorageOption, _}
import com.google.api.client.googleapis.json.GoogleJsonResponseException
import com.google.cloud.http.HttpTransportOptions
import is.hail.io.fs.FSUtil.{containsWildcard, dropTrailingSlash}
import is.hail.services.retryTransientErrors
Expand Down Expand Up @@ -138,10 +137,12 @@ class GoogleStorageFS(
try {
makeRequest(Seq())
} catch {
case exc: StorageException =>
retryIfRequesterPays(exc, exc.getMessage(), exc.getCode(), makeRequest, makeUserProjectOption, bucket)
case exc: GoogleJsonResponseException =>
retryIfRequesterPays(exc, exc.getMessage(), exc.getStatusCode(), makeRequest, makeUserProjectOption, bucket)
case exc: IOException =>
exc.getCause() match {
case cause: StorageException =>
retryIfRequesterPays(cause, cause.getMessage(), cause.getCode(), makeRequest, makeUserProjectOption, bucket)
}
throw exc
}
}

Expand Down Expand Up @@ -321,11 +322,14 @@ class GoogleStorageFS(
.build()
).getResult() // getResult is necessary to cause this to go to completion
} catch {
case exc: StorageException =>
retryCopyIfRequesterPays(exc, exc.getMessage(), exc.getCode())
case exc: GoogleJsonResponseException =>
retryCopyIfRequesterPays(exc, exc.getMessage(), exc.getStatusCode())
case exc: IOException =>
exc.getCause() match {
case cause: StorageException =>
retryCopyIfRequesterPays(cause, cause.getMessage(), cause.getCode())
}
throw exc
}

if (deleteSource)
storage.delete(srcId)
}
Expand Down

0 comments on commit ff1bb1a

Please sign in to comment.