Class Exceptions
java.lang.Object
com.github.tomakehurst.wiremock.common.Exceptions
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringstatic voidstatic <T> TthrowUnchecked(Throwable ex, Class<T> ignoredReturnType) 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 voidstatic <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, null); // does not actually return, throws the exception } }- Parameters:
ex- The exception that will be thrown, unwrapped and uncheckedignoredReturnType- 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
-