From: David ‘Bombe’ Roden Date: Sat, 9 Feb 2013 02:01:27 +0000 (+0100) Subject: Log exception when a JSON reply can not be generated. X-Git-Tag: 0.8.5^2~3^2~14 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=068d00d1b134c10e2aa6ebaf1af8dc7bf4df83a0;p=Sone.git Log exception when a JSON reply can not be generated. --- diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java index dbee28b..994f90c 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java @@ -22,6 +22,8 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.net.URI; +import java.util.logging.Level; +import java.util.logging.Logger; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.web.WebInterface; @@ -30,6 +32,7 @@ import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.io.Closer; import net.pterodactylus.util.json.JsonObject; import net.pterodactylus.util.json.JsonUtils; +import net.pterodactylus.util.logging.Logging; import net.pterodactylus.util.web.Page; import net.pterodactylus.util.web.Response; import freenet.clients.http.SessionManager.Session; @@ -43,6 +46,9 @@ import freenet.clients.http.ToadletContext; */ public abstract class JsonPage implements FreenetPage { + /** The logger. */ + private static final Logger logger = Logging.getLogger(JsonPage.class); + /** The path of the page. */ private final String path; @@ -226,6 +232,7 @@ public abstract class JsonPage implements FreenetPage { JsonObject jsonObject = createJsonObject(request); return response.setStatusCode(200).setStatusText("OK").setContentType("application/json").write(JsonUtils.format(jsonObject)); } catch (Exception e1) { + logger.log(Level.WARNING, "Error executing JSON page!", e1); return response.setStatusCode(500).setStatusText(e1.getMessage()).setContentType("text/plain").write(dumpStackTrace(e1)); } }