From 5040b06d9f88b696a68e97b20d223dbb5cd594e8 Mon Sep 17 00:00:00 2001 From: Tom Morris Date: Thu, 7 Oct 2010 14:20:28 +0000 Subject: [PATCH] Make exceptions more specific for load errors. Still no error returned to user though (just hangs) git-svn-id: http://google-refine.googlecode.com/svn/trunk@1450 7d457c2a-affb-35e4-300a-418c747d4874 --- .../com/google/refine/commands/Command.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/main/src/com/google/refine/commands/Command.java b/main/src/com/google/refine/commands/Command.java index a0c0ab480..e25035329 100644 --- a/main/src/com/google/refine/commands/Command.java +++ b/main/src/com/google/refine/commands/Command.java @@ -103,16 +103,25 @@ public abstract class Command { * @throws ServletException */ protected Project getProject(HttpServletRequest request) throws ServletException { - if (request == null) throw new IllegalArgumentException("parameter 'request' should not be null"); - try { - Project p = ProjectManager.singleton.getProject(Long.parseLong(request.getParameter("project"))); - if (p != null) { - return p; - } - } catch (Exception e) { - // ignore + if (request == null) { + throw new IllegalArgumentException("parameter 'request' should not be null"); + } + String param = request.getParameter("project"); + if (param == null || "".equals(param)) { + throw new ServletException("Can't find project: missing ID parameter"); + } + Long id; + try { + id = Long.parseLong(param); + } catch (NumberFormatException e) { + throw new ServletException("Can't find project: badly formatted id #", e); + } + Project p = ProjectManager.singleton.getProject(id); + if (p != null) { + return p; + } else { + throw new ServletException("Failed to find project id #" + param + " - may be corrupt"); } - throw new ServletException("Can't find project: missing or bad URL parameter"); } /**