Answers.Body: <p>I currently cannot see any way of achieving this as the only appropriate event that exists in the <code>yii\queue\Queue</code> class, <code>afterError</code>, is called before the job is failed in the <code>handleError</code> method of <code>craft\queue\Queue</code>. So your best bet would be to convince P&amp;T that there is a valid use case for adding an extra event that will let you prevent the fail error from appearing.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-04T13:54:23.417Z
Answers.Text: Thanks @Ben, yes I could never figure out a way around this.
Answers.UserDisplayName: Jai Redden
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-13T13:56:31.257Z
Answers.LastActivityDate: 2018-09-13T13:56:31.257Z
Answers.UserDisplayName: Ben Croker
Body: <p>I have an instance of BaseJob that I occasionally queue up that involves reading an XML file from another server. However, requests to that server are rate-limited, and so occasionally it will fail with an error.</p>
  
  <p>I don't mind this in terms of the logic of how it works - I just request another version a while later. However, every time it fails, it adds a message into the "Failed" tab in the CMS.</p>
  
  <p>Is there any way to prevent/override this? I have tried suppressing errors in the job, I've tried wrapping the whole thing within a try/catch block, but nothing seems to work - whenever it fails, it is logged in the CMS.</p>
  
  <p>Thanks.</p>
  
Tags: <tasks>
Title: How to prevent "Failed" errors in job scheduler in Craft CMS 3?
ThreadText: # How to prevent "Failed" errors in job scheduler in Craft CMS 3?
  
  (Asked by: username_0 on 2018-06-19)
  
  I have an instance of BaseJob that I occasionally queue up that involves reading an XML file from another server. However, requests to that server are rate-limited, and so occasionally it will fail with an error.
  
  I don't mind this in terms of the logic of how it works - I just request another version a while later. However, every time it fails, it adds a message into the "Failed" tab in the CMS.
  
  Is there any way to prevent/override this? I have tried suppressing errors in the job, I've tried wrapping the whole thing within a try/catch block, but nothing seems to work - whenever it fails, it is logged in the CMS.
  
  Thanks.
  
  **Tags:** tasks
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-09-13. Score: 2 | Accepted answer
  
  I currently cannot see any way of achieving this as the only appropriate event that exists in the `yii\queue\Queue` class, `afterError`, is called before the job is failed in the `handleError` method of `craft\queue\Queue`. So your best bet would be to convince P&T that there is a valid use case for adding an extra event that will let you prevent the fail error from appearing.
  
  > **Comments:**
  > **username_0**: Thanks @Ben, yes I could never figure out a way around this.  
  
  ---
  
  