Handle done and error states for tasks.