Skip to content

Commit

Permalink
#21 feat: S3UploadException 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
jinno321 committed Oct 9, 2024
1 parent 1bf1b72 commit a2406d6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package web3.exception.S3;

public class S3UploadException extends Exception{

public S3UploadException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.model.*;
import web3.domain.wallet.Wallet;
import web3.exception.S3.S3UploadException;
import web3.properties.S3Properties;
import web3.repository.wallet.WalletRepository;

Expand Down Expand Up @@ -402,7 +403,7 @@ public void deletePdf(String urlToDelete) {
}

@Transactional
public void deletePdfForPage(Wallet wallet, int pageNumberToRemove) throws IOException {
public void deletePdfForPage(Wallet wallet, int pageNumberToRemove) throws IOException,S3UploadException {
String pdfUrl = wallet.getPdfUrl();
byte[] originalPdfBytes = getPdf(pdfUrl).readAllBytes();
String fileName = extractKeyFromUrl(pdfUrl);
Expand Down Expand Up @@ -431,7 +432,7 @@ public void deletePdfForPage(Wallet wallet, int pageNumberToRemove) throws IOExc
try {
uploadToS3(fileName, newMetadata, finalPdfBytes);
} catch (S3Exception e) {
throw new IOException("Failed to upload pdf to S3: " + e.getMessage());
throw new S3UploadException("Failed to upload pdf to S3: " + e.getMessage());
}
}
}
Expand Down

0 comments on commit a2406d6

Please sign in to comment.