<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>

CC BY-SA 4.0
2019-02-04T13:54:23.417Z
Thanks @Ben, yes I could never figure out a way around this.
Jai Redden
CC BY-SA 4.0
2018-09-13T13:56:31.257Z
2018-09-13T13:56:31.257Z
Ben Croker
<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>

<tasks>
How to prevent "Failed" errors in job scheduler in Craft CMS 3?
# 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.  

---

