Package org.eclipse.xtext.xbase.lib
Class Exceptions
java.lang.Object
org.eclipse.xtext.xbase.lib.Exceptions
Useful helper methods when dealing with exceptions.
- Author:
- Sven Efftinge - Initial contribution and API
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic RuntimeException
Throws the given exception and sneaks it through any compiler checks.
-
Constructor Details
-
Exceptions
public Exceptions()
-
-
Method Details
-
sneakyThrow
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:
NullPointerException
- ift
isnull
.
-