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.



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.

  • Thanks @Ben, yes I could never figure out a way around this.
    – Jai Redden
    Feb 4 '19 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.