* #1497 Throw dedicated exception for invalid YAML files and handle it on startup - Wrap SnakeYAML exceptions when loading config.yml and commands.yml on startup into own exception type - Handle exception type on startup with specific error message * #1497 Fix inaccurate JavaDoc comment
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package fr.xephi.authme.service.yaml;
|
||||
|
||||
import ch.jalu.configme.resource.YamlFileResource;
|
||||
import org.yaml.snakeyaml.parser.ParserException;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Creates {@link YamlFileResource} objects.
|
||||
*/
|
||||
public final class YamlFileResourceProvider {
|
||||
|
||||
private YamlFileResourceProvider() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link YamlFileResource} instance for the given file. Wraps SnakeYAML's parse exception
|
||||
* into an AuthMe exception.
|
||||
*
|
||||
* @param file the file to load
|
||||
* @return the generated resource
|
||||
*/
|
||||
public static YamlFileResource loadFromFile(File file) {
|
||||
try {
|
||||
return new YamlFileResource(file);
|
||||
} catch (ParserException e) {
|
||||
throw new YamlParseException(file.getPath(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user