Permalink
Browse files

Demonstrating Error Handling.

  • Loading branch information...
1 parent 0201e5d commit bdb744cf93027411304782637554b4255fcaf4b1 @danbev danbev committed Oct 9, 2012
@@ -2,7 +2,14 @@
public class Error {
- public void index() {
- System.out.println("Error page!");
+ public void index(Exception e) {
+ System.out.println("[Error] " + e);
+ }
+
+ public void security() {
+ }
+
+ public void throwException() {
+ throw new RuntimeException("Demo Exception");
}
}
@@ -20,6 +20,7 @@
import org.jboss.aerogear.controller.demo.model.Car;
import org.jboss.aerogear.controller.demo.model.User;
import org.jboss.aerogear.controller.router.AbstractRoutingModule;
+import org.jboss.aerogear.security.exception.AeroGearSecurityException;
/**
* Routes are the core of aerogear-controller–demo.
@@ -39,8 +40,11 @@
public void configuration() {
route()
- .on(SecurityException.class)
- .to(Error.class).index();
+ .on(AeroGearSecurityException.class)
+ .to(Error.class).security();
+ route()
+ .on(Exception.class)
+ .to(Error.class).index(param(Exception.class));
route()
.from("/")
.on(RequestMethod.GET)
@@ -69,5 +73,10 @@ public void configuration() {
.from("/register")
.on(RequestMethod.POST)
.to(Register.class).register(param(User.class));
+
+ route()
+ .from("/throwException")
+ .on(RequestMethod.GET)
+ .to(Error.class).throwException();
}
}
@@ -5,9 +5,7 @@
<hr />
</div>
<div class="sixteen columns">
- <p>maybe you should try the <a href="delorean">restricted delorean page</a></p>
- <p><a href="login">Login</a></p>
- <p><a href="register">Register</a></p>
+ <p>${requestScope['org.jboss.aerogear.controller.exception']}</p>
</div>
</div>
<jsp:include page="../../template/footer.jsp" />
@@ -0,0 +1,13 @@
+<jsp:include page="../../template/header.jsp" />
+<div class="container">
+ <div class="sixteen columns">
+ <h1 class="remove-bottom" style="margin-top: 40px">Security error page</h1>
+ <hr />
+ </div>
+ <div class="sixteen columns">
+ <p>maybe you should try the <a href="delorean">restricted delorean page</a></p>
+ <p><a href="login">Login</a></p>
+ <p><a href="register">Register</a></p>
+ </div>
+</div>
+<jsp:include page="../../template/footer.jsp" />
@@ -18,6 +18,9 @@
</ul>
</form>
</div>
+ <div class="sixteen columns">
+ <p>maybe you should try out the general <a href="throwException">error handling</a></p>
+ </div>
</div>
<jsp:include page="../../template/footer.jsp" />

0 comments on commit bdb744c

Please sign in to comment.