Permalink
Browse files

Merged 7cad3498bef6

  • Loading branch information...
2 parents 198c80f + bd9a845 commit 2aa12ee8c40d3f47479a7d6ec27cc9728367a827 @jordansjones committed Aug 28, 2011
@@ -1,6 +1,7 @@
package nextmethod.web.mvc;
import com.google.inject.Injector;
+import nextmethod.web.HttpException;
import nextmethod.web.routing.RequestContext;
import nextmethod.web.routing.RouteData;
@@ -33,7 +34,7 @@ public RouteData getRouteData() {
}
@Override
- protected void executeCore() {
+ protected void executeCore() throws HttpException{
// If code in this method needs to be updated, please also check the beginExecuteCore() and
// endExecuteCore() methods of AsyncController to see if that code also must be updated.
possiblyLoadTempData();
@@ -48,9 +49,8 @@ protected void executeCore() {
}
}
- protected void handleUnknownAction(final String actionName) {
- // TODO: This should be an HttpException with a message.
- throw new RuntimeException();
+ protected void handleUnknownAction(final String actionName) throws HttpException {
+ throw new HttpException(404, actionName + "not found.");
}
void possiblyLoadTempData() {
@@ -1,5 +1,6 @@
package nextmethod.web.mvc;
+import nextmethod.web.HttpException;
import nextmethod.web.InvalidOperationException;
import nextmethod.web.routing.RequestContext;
@@ -17,7 +18,7 @@
private boolean validateRequest;
@Override
- public void execute(final RequestContext requestContext) {
+ public void execute(final RequestContext requestContext) throws HttpException {
checkNotNull(requestContext);
verifyExecuteCalledOnce();
@@ -29,8 +30,7 @@ protected void initialize(final RequestContext requestContext) {
controllerContext = new ControllerContext(requestContext, this);
}
- protected abstract void executeCore();
-
+ protected abstract void executeCore() throws HttpException;
public ControllerContext getControllerContext() {
return controllerContext;
@@ -1,12 +1,13 @@
package nextmethod.web.mvc;
+import nextmethod.web.HttpException;
import nextmethod.web.routing.RequestContext;
/**
*
*/
public interface IController {
- void execute(RequestContext requestContext);
+ void execute(RequestContext requestContext) throws HttpException;
}
@@ -6,8 +6,15 @@
*
*/
public class HttpException extends ServletException {
+ private int httpErrorCode;
- public HttpException(final String message) {
- super(message);
+ public HttpException(final int httpErrorCode, final String message) {
+ super(message);
+ this.httpErrorCode = httpErrorCode;
}
+
+ public int getHttpErrorCode()
+ {
+ return httpErrorCode;
+ }
}

0 comments on commit 2aa12ee

Please sign in to comment.