[thread] Add onFailure for Tasks
It would be useful to be able to execute some code when a Task fails.