Fix task error handling