Handling ValidationExceptions in interceptors

Please do not merge it yet, it's a work in progress related with #858 

My idea here is to extract classes to better deal with exception handling so then we could reuse the exception handling code to develop that  `@ValidationInterceptor ` feature that @lucascs proposed.

I've implemented a `Try` class, similar to the scala's Try monad. Is not a proper monad here, but I think it's a nice abstraction to handle exceptions, what do you think? @lucascs @Turini @garcia-jj 
I like the query method :) to know about the state of the object.

On Mon, Nov 10, 2014 at 3:47 PM, Otávio Garcia <notifications@github.com>
wrote:

> In vraptor-core/src/main/java/br/com/caelum/vraptor/util/Try.java:
>
> > +
> > +	public static class Success<T> extends Try {
> > +		private final T result;
> > +
> > +		public Success(T result) {
> > +			this.result = result;
> > +		}
> > +
> > +		@Override
> > +		public boolean failed() {
> > +			return false;
> > +		}
> > +
> > +		@Override
> > +		public Exception getException() {
> > +			throw new UnsupportedOperationException();
>
> May be null is better than this exception, because
>
> 1) Success means that have no exception, so return null is right;
>
> 2) in the view we can do something like ${not empty try.exception}. If
> this exception we need to write more code: ${try.failed ? try.exception :
> null};
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/caelum/vraptor4/pull/873/files#r20098586>.
>



-- 
Alberto Souza

www.caelum.com.br
www.codecrushing.com/products/book-play-framework-java
www.leanpub.com/playframeworknapratica
www.alots.wordpress.com/