Class Exceptions
java.lang.Object
com.github.tomakehurst.wiremock.common.Exceptions
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
static void
static <T> T
throwUnchecked
(Throwable ex, Class<T> returnType) Because this method throws an unchecked exception, when it is called in a method with a return type the compiler does not know the method is exiting, requiring a further line to return null or throw an unchecked exception directly.static void
static <T> T
-
Constructor Details
-
Exceptions
public Exceptions()
-
-
Method Details
-
throwUnchecked
Because this method throws an unchecked exception, when it is called in a method with a return type the compiler does not know the method is exiting, requiring a further line to return null or throw an unchecked exception directly. This generified method allows this to be avoided by tricking the compiler by adding a return statement as so:String someMethod() { try { somethingThatThrowsException(); } catch (Exception e) { return throwUnchecked(e, String.class); // does not actually return, throws the exception } }
- Parameters:
ex
- The exception that will be thrown, unwrapped and uncheckedreturnType
- trick to persuade the compiler that a method returns appropriately- Returns:
- Never returns, always throws the passed in exception
-
throwUnchecked
- Parameters:
ex
- The exception that will be thrown, unwrapped and unchecked
-
uncheck
-
uncheck
-
renderStackTrace
-