This is a demo application that demonstrates how you can do advanced error handling with Play.
Run this using sbt.
sbt run
And then go to http://localhost:9000 to see the running web application.
There are multiple exceptions that will be thrown during apps runtime. There needs to be a mechanism that allows separate classes to handle these exceptions.
Using HandledBy annotation in combination with ExceptionHandler interface.
All exception handlers must implement ExceptionHandler, like this:
public class FirstExceptionHandler implements ExceptionHandler {
@Override
public void handleException() {
System.out.println("Handling first exception");
}
}
And the exception must be marked with HandledBy, like this:
@HandledBy(FirstExceptionHandler.class)
public class FirstException extends RuntimeException {
...
}