Additional Exception catching for errors which might occur when loading JSON files

This commit is contained in:
Brettflan 2013-04-18 02:08:41 -05:00
parent 8487bafac0
commit d8564a050f
2 changed files with 12 additions and 5 deletions

View File

@ -8,7 +8,6 @@ import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.libs.com.google.gson.Gson;
import org.bukkit.craftbukkit.libs.com.google.gson.JsonSyntaxException;
import com.massivecraft.factions.zcore.util.DiscUtil;
import com.massivecraft.factions.zcore.util.TextUtil;
@ -223,7 +222,7 @@ public abstract class EntityCollection<E extends Entity>
{
return this.gson.fromJson(content, type);
}
catch(JsonSyntaxException ex)
catch(Exception ex)
{
Bukkit.getLogger().log(Level.WARNING, "JSON error encountered loading \"" + file + "\": " + ex.getLocalizedMessage());

View File

@ -165,7 +165,15 @@ public class Persist {
return null;
}
return (T) p.gson.fromJson(content, typeOfT);
}
try
{
return (T) p.gson.fromJson(content, typeOfT);
}
catch (Exception ex)
{ // output the error message rather than full stack trace; error parsing the file, most likely
p.log(Level.WARNING, ex.getMessage());
}
return null;
}
}