Top Description Constructors Methods
org.eclipse.xtext.xbase.lib

public Class Exceptions

extends Object
Class Inheritance
Annotations
@GwtCompatible
Imports
com.google.common.annotations.GwtCompatible

Useful helper methods when dealing with exceptions.
Author
Sven Efftinge - Initial contribution and API

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static RuntimeException

Returns:

never returns anything since t is always thrown.
sneakyThrow
(Throwable
the throwable that should be sneaked through compiler checks. May not be null.
t
)

Throws the given exception and sneaks it through any compiler checks.

private static <T extends Throwable> void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Exceptionsback to summary
public Exceptions()

Method Detail

sneakyThrowback to summary
public static RuntimeException sneakyThrow(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:Throwable

the throwable that should be sneaked through compiler checks. May not be null.

Returns:RuntimeException

never returns anything since t is always thrown.

Exceptions
NullPointerException:
if t is null.
sneakyThrow0back to summary
private static <T extends Throwable> void sneakyThrow0(Throwable t) throws Throwable-:T
Annotations
@SuppressWarnings:unchecked