Class Exceptions

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

@GwtCompatible public class Exceptions extends Object
Useful helper methods when dealing with exceptions.
Author:
Sven Efftinge - Initial contribution and API
  • Constructor Details

    • Exceptions

      public Exceptions()
  • Method Details

    • sneakyThrow

      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 - the throwable that should be sneaked through compiler checks. May not be null.
      Returns:
      never returns anything since t is always thrown.
      Throws:
      NullPointerException - if t is null.