I've been trying to create a general trycatch method like this:
public static void tryCatchAndLog(Runnable tryThis) {
try {
tryThis.run();
} catch (Throwable throwable) {
Log.Write(throwable);
}
}
However I get an unhandled exception if I try to use it like this:
tryCatchAndLog(() -> {
methodThatThrowsException();
});
How can I implement this so that the compiler knows that tryCatchAndLog will handle the Exception?