Package org.eclipse.xtext.xbase.lib
Class Exceptions
- java.lang.Object
-
- org.eclipse.xtext.xbase.lib.Exceptions
-
@GwtCompatible public class Exceptions extends java.lang.Object
Useful helper methods when dealing with exceptions.
-
-
Constructor Summary
Constructors Constructor Description Exceptions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.RuntimeException
sneakyThrow(java.lang.Throwable t)
Throws the given exception and sneaks it through any compiler checks.
-
-
-
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 benull
.- Returns:
- never returns anything since
t
is always thrown. - Throws:
java.lang.NullPointerException
- ift
isnull
.
-
-