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);