Skip to content

Commit 09f8a42

Browse files
committed
Fixed some exceptioms
1 parent f6d77c4 commit 09f8a42

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

src/main/java/org/hydev/mcpm/client/database/SuperLocalPluginTracker.java

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.hydev.mcpm.client.models.PluginModel;
1212
import org.hydev.mcpm.client.models.PluginVersion;
1313
import org.hydev.mcpm.client.models.PluginYml;
14+
import org.hydev.mcpm.client.models.PluginYml.InvalidPluginMetaStructure;
1415
import org.hydev.mcpm.utils.PluginJarFile;
1516
import org.hydev.mcpm.client.models.PluginTrackerModel;
1617

@@ -66,6 +67,10 @@ private PluginYml readMeta(File jar) {
6667
} catch (IOException e) {
6768
System.out.println("Error reading plugin.yml from " + jar);
6869
return null;
70+
} catch (InvalidPluginMetaStructure e) {
71+
System.out.println("Invalid plugin.yml structure in " + jar);
72+
e.printStackTrace();
73+
return null;
6974
}
7075
}
7176

@@ -335,6 +340,9 @@ public List<String> listOrphanPlugins(boolean considerSoftDependencies) {
335340
// directory
336341

337342
File pluginYmlPath = getPluginFile(name);
343+
if (pluginYmlPath == null) {
344+
throw new FileNotFoundException("Plugin " + name + " not found");
345+
}
338346
PluginYml p = readMeta(pluginYmlPath);
339347
if (p == null)
340348
continue;
@@ -537,24 +545,20 @@ private File getPluginFile(String name) {
537545
// Get the file path of the plugin with name name from the local plugin
538546
// directory
539547
// Return the file path as a File
540-
try {
541-
// Find the file from the plugin directory
542-
File dir = new File(pluginDirectory);
543-
File[] directoryListing = dir.listFiles();
544-
if (directoryListing != null) {
545-
for (File child : directoryListing) {
546-
if (child.getName().equals(name)) {
547-
return child;
548-
}
548+
// Find the file from the plugin directory
549+
550+
File dir = new File(pluginDirectory);
551+
File[] directoryListing = dir.listFiles();
552+
if (directoryListing != null) {
553+
for (File child : directoryListing) {
554+
if (child.getName().equals(name)) {
555+
return child;
549556
}
550-
throw new IllegalArgumentException("Plugin not found, verify whether installed.");
551-
} else {
552-
throw new Exception("Empty Directory.");
553557
}
554-
555-
} catch (IOException e) {
556-
throw new IllegalArgumentException("Plugin not found, error with directory iteration.");
558+
} else {
559+
throw new IllegalArgumentException("Plugin not found, verify whether installed.");
557560
}
561+
return null;
558562
}
559563

560564
/**

0 commit comments

Comments
 (0)