Additional Exception catching for errors which might occur when loading JSON files
This commit is contained in:
parent
8487bafac0
commit
d8564a050f
@ -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());
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user