Skip to content

Conversation

yankewei
Copy link

@yankewei yankewei commented Aug 7, 2025

Add SkipOnException Queue Middleware

Problem

Currently, when a job throws an exception, it either fails or retries. There's no built-in way to make a job complete successfully when certain exceptions occur.

Solution

This PR adds SkipOnException middleware that allows jobs to complete normally when specific exceptions are thrown, instead of failing or retrying.

Usage:

public function middleware()
{
    return [
        new SkipOnException([
            ThirdPartyApiException::class,
            OptionalServiceException::class,
        ]),
    ];
}

Copy link

github-actions bot commented Aug 7, 2025

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@antonkomarev
Copy link
Contributor

But you can use try-catch in the job, to make this behaviour obvious.

@siarheipashkevich
Copy link
Contributor

@yankewei how to handle for example Deadlock exception, which thrown by QueryException and only by parameters inside we can determine that the QueryException is Deadlock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants