Catch file exceptions in CameraConfig and ConfigManager

This commit is contained in:
Matt
2019-11-27 08:58:20 -08:00
parent ebf87c8b2a
commit ca7f15aeb7
2 changed files with 10 additions and 3 deletions

View File

@@ -4,6 +4,7 @@ import com.chameleonvision.util.JacksonHelper;
import com.chameleonvision.vision.pipeline.CVPipelineSettings;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -94,8 +95,13 @@ public class CameraConfig {
private void checkFolder() {
if (!folderExists()) {
if (!(new File(getFolderPath().toUri()).mkdirs())) {
System.err.println("Failed to create camera config folder: " + getFolderPath().toString());
try {
if (!(new File(getFolderPath().toUri()).mkdirs())) {
System.err.println("Failed to create camera config folder: " + getFolderPath().toString());
}
} catch(Exception e) {
if(!(e instanceof java.nio.file.FileAlreadyExistsException || e instanceof java.nio.file.FileAlreadyExistsException))
System.err.println("Failed to create camera config folder: " + getFolderPath().toString());
}
}
}

View File

@@ -32,7 +32,8 @@ public class ConfigManager {
new File(SettingsPath.toUri()).mkdirs();
Files.createDirectory(SettingsPath);
} catch (IOException e) {
e.printStackTrace();
if(!(e instanceof java.nio.file.FileAlreadyExistsException || e instanceof java.nio.file.FileAlreadyExistsException))
e.printStackTrace();
}
}
}