From b076630e8d247cce6c2470ebf8feb8e3d3ddccc7 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Tue, 4 Mar 2008 21:30:14 +0000 Subject: [PATCH] I don't like using an Error here, but too late to introduce a checked exception. I suppose the justification could be that this error is meant to really just abort the processing right there, so it's somewhat akin to ThreadDeath. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@7316 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/StructuredForm.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/hudson/StructuredForm.java b/core/src/main/java/hudson/StructuredForm.java index fad6c696f4..79690fc0fa 100644 --- a/core/src/main/java/hudson/StructuredForm.java +++ b/core/src/main/java/hudson/StructuredForm.java @@ -5,7 +5,6 @@ import org.kohsuke.stapler.Stapler; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; -import javax.servlet.ServletException; import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST; import java.io.IOException; @@ -16,16 +15,20 @@ import java.io.IOException; * @author Kohsuke Kawaguchi */ public class StructuredForm { - public static JSONObject get(StaplerRequest req) throws IOException, ServletException { + public static JSONObject get(StaplerRequest req) { JSONObject o = (JSONObject)req.getAttribute(StructuredForm.class.getName()); if(o==null) { String p = req.getParameter("json"); if(p==null) { // no data submitted - StaplerResponse rsp = Stapler.getCurrentResponse(); - rsp.sendError(SC_BAD_REQUEST,"This page expects a form submission"); - rsp.getWriter().close(); - throw new ServletException("This page expects a form submission"); + try { + StaplerResponse rsp = Stapler.getCurrentResponse(); + rsp.sendError(SC_BAD_REQUEST,"This page expects a form submission"); + rsp.getWriter().close(); + throw new Error("This page expects a form submission"); + } catch (IOException e) { + throw new Error(e); + } } o = JSONObject.fromObject(p); req.setAttribute(StructuredForm.class.getName(),o);