Skip to content

Commit cd607a6

Browse files
committed
refactor : S3Uploader 예외처리 개선
1 parent 153ea22 commit cd607a6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/main/java/org/ezcode/codetest/infrastructure/s3/S3Uploader.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.springframework.web.multipart.MultipartFile;
1111

1212
import com.amazonaws.services.s3.AmazonS3;
13+
import com.amazonaws.services.s3.model.AmazonS3Exception;
1314
import com.amazonaws.services.s3.model.ObjectMetadata;
1415

1516
import lombok.RequiredArgsConstructor;
@@ -51,6 +52,21 @@ public String upload(MultipartFile multipartFile, String dirName) {
5152
return result;
5253

5354
} catch (IOException e) {
55+
log.error("S3 업로드 중 IO 오류 발생",e);
56+
throw new S3Exception(
57+
S3ExceptionCode.S3_UPLOAD_FAILED,
58+
S3ExceptionCode.S3_UPLOAD_FAILED.getStatus(),
59+
S3ExceptionCode.S3_UPLOAD_FAILED.getMessage()
60+
);
61+
} catch (AmazonS3Exception e) {
62+
log.error("S3 서비스 오류 발생: {}", e.getErrorMessage(), e);
63+
throw new S3Exception(
64+
S3ExceptionCode.S3_UPLOAD_FAILED,
65+
S3ExceptionCode.S3_UPLOAD_FAILED.getStatus(),
66+
S3ExceptionCode.S3_UPLOAD_FAILED.getMessage()
67+
);
68+
} catch (Exception e) {
69+
log.error("예상치 못한 업로드 오류 발생", e);
5470
throw new S3Exception(
5571
S3ExceptionCode.S3_UPLOAD_FAILED,
5672
S3ExceptionCode.S3_UPLOAD_FAILED.getStatus(),

0 commit comments

Comments
 (0)