I know how to create a reference to a method that has a String
parameter and returns an int
, it\'s:
Function
Several of the offered solutions use a generic argument of E to pass in the type of the exception which gets thrown.
Take that one step further, and rather than passing in the type of the exception, pass in a Consumer of the type of exception, as in...
Consumer
You might create several re-usable variations of Consumer
which would cover the common exception handling needs of your application.