Class Exceptions


  • public class Exceptions
    extends Object
    • Constructor Detail

      • Exceptions

        public Exceptions()
    • Method Detail

      • exception

        public static <T extends Exception> T exception​(Class<T> exceptionClass,
                                                        String message,
                                                        Object... args)
        Instantiate the provided exception Class. It will look for a constructor compatible with String and Throwable. In case such constructor does not exists, this method will throw an IllegalArgumentException. The message can contain "{}" type placeholders, like with common logging APIs.
        Type Parameters:
        T - the type of the exception
        Parameters:
        exceptionClass - the type of the exception to instantiate
        message - the message (which can contain "{}" type of placeholders)
        args - the arguments to the message, which will replace the "{}" type placeholders. In case of a throwable, it is passed as the second argumet of the exception constructor.
        Returns:
        an instance of the exception
        Throws:
        IllegalArgumentException - in case the exception of the given type does not have an appropriate constructor.