Skip to content

Commit

Permalink
Throw assert if no file extension
Browse files Browse the repository at this point in the history
  • Loading branch information
i-make-robots committed Feb 21, 2025
1 parent 06f8acd commit dd9b648
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,18 @@ public static List<FileNameExtensionFilter> getSaveExtensions() {
public static void save(Turtle turtle,String filename, PlotterSettings settings) throws Exception {
if(filename == null || filename.trim().isEmpty()) throw new InvalidParameterException("filename cannot be empty");

String extension = filename.substring(filename.lastIndexOf("."));
if(extension.isEmpty()) throw new InvalidParameterException("filename must have an extension");

for (TurtleSaver saver : savers) {
if(isValidExtension(filename,saver.getFileNameFilter())) {
try (FileOutputStream out = new FileOutputStream(filename)) {
saver.save(out, turtle,settings);
return;
}
return;
}
}
String extension = filename.substring(filename.lastIndexOf("."));

throw new Exception("TurtleFactory could not save '"+filename+"' : invalid file format '" + extension + "'");
}
}

0 comments on commit dd9b648

Please # to comment.