Skip to content

Commit

Permalink
add invalid YAML format exception for loadYaml
Browse files Browse the repository at this point in the history
  • Loading branch information
Femi-lawal committed Feb 24, 2024
1 parent 68dcaf1 commit fafb0af
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CLI/src/main/java/main/Drifty_CLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import cli.utils.MessageBroker;
import cli.init.Environment;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.error.YAMLException;
import preferences.AppSettings;
import properties.MessageType;
import properties.Program;
Expand Down Expand Up @@ -262,6 +263,8 @@ private static Map<String, List<String>> loadYamlData() {
data = new HashMap<>();
}
data.computeIfAbsent("links", k -> new ArrayList<>()); // Ensure 'links' list exists
} catch (YAMLException e) {
messageBroker.msgLogError("Invalid YAML format in file: " + e.getMessage());
} catch (IOException e) {
messageBroker.msgLogError("Error reading YAML file: " + e.getMessage());
}
Expand Down

0 comments on commit fafb0af

Please sign in to comment.