Catching all exceptions thrown while executing the provided task.
Executes the task. Catches any exception, if thrown, and prints the stacktrace.