Tweaked some more exceptions, get messages passed

By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot 2011-01-05 22:56:12 +00:00
parent 14cfdcc567
commit 88c998f4a2
4 changed files with 8 additions and 8 deletions

View file

@ -57,6 +57,6 @@ public class InvalidDescriptionException extends Exception {
@Override @Override
public String getMessage() { public String getMessage() {
return super.getMessage(); return message;
} }
} }

View file

@ -81,10 +81,6 @@ public final class PluginDescriptionFile {
} }
private void loadMap(Map<String, Object> map) throws InvalidDescriptionException { private void loadMap(Map<String, Object> map) throws InvalidDescriptionException {
if (name == null) {
throw new InvalidDescriptionException("Name is not defined");
}
try { try {
name = map.get("name").toString(); name = map.get("name").toString();
} catch (NullPointerException ex) { } catch (NullPointerException ex) {

View file

@ -56,8 +56,9 @@ public interface PluginManager {
* @param file File containing the plugin to load * @param file File containing the plugin to load
* @return The Plugin loaded, or null if it was invalid * @return The Plugin loaded, or null if it was invalid
* @throws InvalidPluginException Thrown when the specified file is not a valid plugin * @throws InvalidPluginException Thrown when the specified file is not a valid plugin
* @throws InvalidDescriptionException Thrown when the specified file contains an invalid description
*/ */
public Plugin loadPlugin(File file) throws InvalidPluginException; public Plugin loadPlugin(File file) throws InvalidPluginException, InvalidDescriptionException;
/** /**
* Loads the plugins contained within the specified directory * Loads the plugins contained within the specified directory

View file

@ -79,7 +79,9 @@ public final class SimplePluginManager implements PluginManager {
try { try {
plugin = loadPlugin(file); plugin = loadPlugin(file);
} catch (InvalidPluginException ex) { } catch (InvalidPluginException ex) {
Logger.getLogger(SimplePluginManager.class.getName()).log(Level.SEVERE, "Could not load " + file.getPath() + " in " + directory.getPath(), ex); Logger.getLogger(SimplePluginManager.class.getName()).log(Level.SEVERE, "Could not load " + file.getPath() + " in " + directory.getPath() + ": " + ex.getMessage(), ex);
} catch (InvalidDescriptionException ex) {
Logger.getLogger(SimplePluginManager.class.getName()).log(Level.SEVERE, "Could not load " + file.getPath() + " in " + directory.getPath() + ": " + ex.getMessage(), ex);
} }
if (plugin != null) { if (plugin != null) {
@ -98,8 +100,9 @@ public final class SimplePluginManager implements PluginManager {
* @param file File containing the plugin to load * @param file File containing the plugin to load
* @return The Plugin loaded, or null if it was invalid * @return The Plugin loaded, or null if it was invalid
* @throws InvalidPluginException Thrown when the specified file is not a valid plugin * @throws InvalidPluginException Thrown when the specified file is not a valid plugin
* @throws InvalidDescriptionException Thrown when the specified file contains an invalid description
*/ */
public Plugin loadPlugin(File file) throws InvalidPluginException { public Plugin loadPlugin(File file) throws InvalidPluginException, InvalidDescriptionException {
Set<Pattern> filters = fileAssociations.keySet(); Set<Pattern> filters = fileAssociations.keySet();
Plugin result = null; Plugin result = null;