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
This commit is contained in:
Tom Morris 2010-10-07 14:20:28 +00:00
parent ea28784e8b
commit 5040b06d9f

View File

@ -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");
}
/**