summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Framework/Serialisation/JsonHelper.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/StardewModdingAPI/Framework/Serialisation/JsonHelper.cs')
-rw-r--r--src/StardewModdingAPI/Framework/Serialisation/JsonHelper.cs16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/StardewModdingAPI/Framework/Serialisation/JsonHelper.cs b/src/StardewModdingAPI/Framework/Serialisation/JsonHelper.cs
index 64d8738e..6431394c 100644
--- a/src/StardewModdingAPI/Framework/Serialisation/JsonHelper.cs
+++ b/src/StardewModdingAPI/Framework/Serialisation/JsonHelper.cs
@@ -51,7 +51,21 @@ namespace StardewModdingAPI.Framework.Serialisation
}
// deserialise model
- return JsonConvert.DeserializeObject<TModel>(json, this.JsonSettings);
+ try
+ {
+ return JsonConvert.DeserializeObject<TModel>(json, this.JsonSettings);
+ }
+ catch (JsonReaderException ex)
+ {
+ string message = $"The file at {fullPath} doesn't seem to be valid JSON.";
+
+ string text = File.ReadAllText(fullPath);
+ if (text.Contains("“") || text.Contains("”"))
+ message += " Found curly quotes in the text; note that only straight quotes are allowed in JSON.";
+
+ message += $"\nTechnical details: {ex.Message}";
+ throw new JsonReaderException(message);
+ }
}
/// <summary>Save to a JSON file.</summary>