Added a check for the config file
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2022-05-01 23:02:31 -04:00
parent 3742c44c40
commit ffb7d2d9f1
3 changed files with 16 additions and 5 deletions

View File

@ -1,5 +1,6 @@
package tech.bitgoblin.config;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
@ -17,13 +18,18 @@ public class Config {
// parse config file
try {
this.parseConfig();
String value = result.getString("repo");
String value = this.result.getString("repo");
System.out.println(value);
} catch (IOException e) {
throw new RuntimeException(e);
System.out.println("Unable to read config file; please check that " + this.configPath + " is available.");
System.exit(1);
}
}
public String getString(String key) {
return this.result.getString(key);
}
private void parseConfig() throws IOException {
// parse config file
Path source = Paths.get(this.configPath);