Skip to content

Commit ac274c9

Browse files
committed
feat: 초기화클래스 예외처리로직추가
1 parent 0ab2e03 commit ac274c9

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/main/java/com/sprint/mission/discodeit/util/DataInitializer.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,24 @@ public class DataInitializer {
1818

1919
public static void clearSerializedData() {
2020
for (String path : FILE_PATHS) {
21-
File file = Path.of(path).toFile();
22-
if (file.exists()) {
23-
boolean deleted = file.delete();
24-
if (deleted) {
25-
System.out.println("초기화 완료 " + file.getName());
21+
try {
22+
File file = Path.of(path).toFile();
23+
24+
if (file.exists()) {
25+
boolean deleted = file.delete();
26+
if (deleted) {
27+
System.out.println("초기화 완료 " + file.getName());
28+
} else {
29+
System.out.println("초기화 실패 " + file.getName());
30+
}
2631
} else {
27-
System.out.println("초기화 실패 " + file.getName());
32+
System.out.println("초기화할 파일이 존재하지 않음 " + file.getName());
2833
}
34+
} catch (Exception e) {
35+
System.out.println("!예외 발생!");
36+
System.out.println(" 예외 타입: " + e.getClass().getSimpleName());
37+
System.out.println(" 메시지: " + e.getMessage());
38+
e.printStackTrace();
2939
}
3040
}
3141
}

0 commit comments

Comments
 (0)