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

@@ -164,8 +164,16 @@ public class Persist {
if (content == null) {
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;
}
}