*
* If preloading fails for any reason, we just output an empty object.
*/
private void injectPreloads(Gadget gadget, Node scriptTag) {
JSONObject preload = new JSONObject();
Preloads preloads = gadget.getPreloads();
for (String name : preloads.getKeys()) {
try {
preload.put(name, preloads.getData(name).toJson());
} catch (PreloadException e) {
// This will be thrown in the event of some unexpected exception. We can move on.
LOG.log(Level.WARNING, "Unexpected error attempting to preload " + name, e);
} catch (JSONException e) {
// Shouldn't ever happen. Probably indicates a big problem, so we'll abort.