title: Celery chain - if any tasks fail, do x, else y
body: <p>I'm just getting into Celery chains in my Django project. I have the following function:</p>
  <pre><code>def orchestrate_tasks_for_account(account_id):
  
      # Get the account, set status to 'SYNC' until the chain is complete
      account = Account.objects.get(id=account_id)
      account.status = &quot;SYNC&quot;
      account.save()
  
      chain = task1.s(account_id) | task2.s() | task3.s()
      chain()
  
      # if any of the tasks in the chain failed, set account.status = 'ERROR'
      # else set the account.status = 'OK'
  </code></pre>
  <p>The chain works as expected, but I'm not sure how to take feedback from the chain and update the account based on the results</p>
  <p>In other words, I'd like to set the account status to 'ERROR' if any of the tasks in the chain fail, otherwise I'd like to set the account status to 'OK'</p>
  <p>I'm confused by the Celery documentation on how to handle an error with an if/else like I've commented in the last two lines above.</p>
  <p>Does anyone have experience with this?</p>