Skip to content

Commit 8dd1a0b

Browse files
committed
Use dedicated exception for absolute path
1 parent 7ebf517 commit 8dd1a0b

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

DriveBackup/src/main/java/ratismal/drivebackup/UploadThread.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import ratismal.drivebackup.config.configSections.ExternalBackups.ExternalMySQLSource;
1717
import ratismal.drivebackup.config.configSections.ExternalBackups.ExternalMySQLSource.MySQLDatabaseBackup;
1818
import ratismal.drivebackup.constants.Permission;
19+
import ratismal.drivebackup.exceptions.AbsolutePathException;
1920
import ratismal.drivebackup.handler.listeners.PlayerListener;
2021
import ratismal.drivebackup.plugin.Scheduler;
2122
import ratismal.drivebackup.uploaders.Authenticator;
@@ -377,7 +378,7 @@ private void makeBackupFile(String location, LocalDateTimeFormatter formatter, L
377378
try {
378379
ServerUtil.setAutoSave(false);
379380
fileUtil.makeBackup(location, formatter, blackList);
380-
} catch (IllegalArgumentException exception) {
381+
} catch (AbsolutePathException exception) {
381382
logger.log(intl("backup-failed-absolute-path"));
382383
return;
383384
} catch (SecurityException exception) {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package ratismal.drivebackup.exceptions;
2+
3+
public class AbsolutePathException extends Exception {
4+
5+
public AbsolutePathException(String message) {
6+
super(message);
7+
}
8+
9+
}

DriveBackup/src/main/java/ratismal/drivebackup/util/FileUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import ratismal.drivebackup.UploadThread.UploadLogger;
66
import ratismal.drivebackup.config.ConfigParser;
77
import ratismal.drivebackup.config.ConfigParser.Config;
8+
import ratismal.drivebackup.exceptions.AbsolutePathException;
89

910
import java.io.File;
1011
import java.io.FileInputStream;
@@ -72,7 +73,7 @@ public TreeMap<Long, File> getLocalBackups(String location, LocalDateTimeFormatt
7273
public void makeBackup(@NotNull String location, LocalDateTimeFormatter formatter, List<String> blacklistGlobs) throws Exception {
7374
Config config = ConfigParser.getConfig();
7475
if (location.charAt(0) == '/') {
75-
throw new IllegalArgumentException("Location cannot start with a slash");
76+
throw new AbsolutePathException("Location cannot start with a slash");
7677
}
7778
ZonedDateTime now = ZonedDateTime.now(config.advanced.dateTimezone);
7879
String fileName = formatter.format(now);

0 commit comments

Comments
 (0)