org.eclipse.xtext.xbase.lib
Class Exceptions

java.lang.Object
  extended by org.eclipse.xtext.xbase.lib.Exceptions

public class Exceptions
extends java.lang.Object

Useful helper methods when dealing with exceptions.

Author:
Sven Efftinge - Initial contribution and API

Constructor Summary
Exceptions()
           
 
Method Summary
static java.lang.RuntimeException sneakyThrow(java.lang.Throwable t)
          Throws the given exception and sneaks it through any compiler checks.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Exceptions

public Exceptions()
Method Detail

sneakyThrow

public static java.lang.RuntimeException sneakyThrow(java.lang.Throwable t)
Throws the given exception and sneaks it through any compiler checks. This allows to throw checked exceptions without the need to declare it. Clients should use the following idiom to trick static analysis and dead code checks:
 throw sneakyThrow(new CheckedException("Catch me if you can ;-)")).
 
This method is heavily inspired by project Lombok.

Parameters:
t - the throwable that should be sneaked through compiler checks. May not be null.
Returns:
never returns anything since t is always thrown.
Throws:
java.lang.NullPointerException - if t is null.