From 79b9fa81931c54e593a546e7b14d53903d201041 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 22 Mar 2016 11:06:02 +0100 Subject: [PATCH] 0.3h Improve debug output on json syntax exception --- .../massivecraft/massivecore/store/Coll.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/com/massivecraft/massivecore/store/Coll.java b/src/com/massivecraft/massivecore/store/Coll.java index 3a505c1c..806cd005 100644 --- a/src/com/massivecraft/massivecore/store/Coll.java +++ b/src/com/massivecraft/massivecore/store/Coll.java @@ -24,6 +24,7 @@ import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.xlib.gson.Gson; import com.massivecraft.massivecore.xlib.gson.JsonElement; import com.massivecraft.massivecore.xlib.gson.JsonObject; +import com.massivecraft.massivecore.xlib.gson.JsonSyntaxException; public class Coll> extends CollAbstract { @@ -498,12 +499,23 @@ public class Coll> extends CollAbstract } } + if ( ! this.remoteEntryIsOk(id, remoteEntry)) return; JsonObject raw = remoteEntry.getKey(); Long mtime = remoteEntry.getValue(); - if ( ! this.remoteEntryIsOk(id, remoteEntry)) return; // Calculate temp but handle raw cases. - E temp = this.getGson().fromJson(raw, this.getEntityClass()); + E temp; + + try + { + temp = this.getGson().fromJson(raw, this.getEntityClass()); + } + catch (JsonSyntaxException ex) + { + logLoadError(id, ex.getMessage()); + return; + } + E entity = this.getFixed(id, false); if (entity != null) { @@ -565,7 +577,7 @@ public class Coll> extends CollAbstract { MassiveCore.get().log(Txt.parse("Database could not load entity. You edited a file manually and made wrong JSON?")); MassiveCore.get().log(Txt.parse("Entity: %s", entityId)); - MassiveCore.get().log(Txt.parse("Collection: %s", this.getName())); + MassiveCore.get().log(Txt.parse("Collection: %s", this.getDebugName())); MassiveCore.get().log(Txt.parse("Error: %s", error)); }