Repository navigation
Conversation
#9: expose job-processing exceptions - Add Queue::setOnError()/getOnError(): a callback invoked for every caught throwable while processing a job, with signature fn(?Job $job, Throwable $e, int $attempts, bool $willRetry). It fires for both intermediate retries and terminal failures, letting applications bridge queue failures into a centralized logger with full exception context. - Enrich the failed job's failReason with the exception class in addition to the message. - QueueFacade::setOnError() passthrough. - Invalid (non-Job) payloads are reported to the callback as terminal failures with a null job. Additive and opt-in: behavior is unchanged without a callback. #6: standardize README - Add Table of Contents and Testing/Examples/Contributing/Support/Changelog sections; document setOnError; fix an inaccurate getFailed() retry example. Closes #9, closes #6
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10 +/- ##
============================================
+ Coverage 96.03% 97.72% +1.69%
- Complexity 78 84 +6
============================================
Files 4 4
Lines 252 264 +12
============================================
+ Hits 242 258 +16
+ Misses 10 6 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Adds an opt-in error callback so applications can observe job-processing failures, and standardizes the README.
Motivation
Queue::process()caught everyThrowablefromJob::handle()and discarded everything but the message string. A globally registered error handler never saw queue-job failures, intermediate (pre-max-attempts) failures were recorded nowhere, and consumers had no failure hook. This makes background work a blind spot for centralized error logging.Closes #9 and #6.
Changes
#9 — expose job-processing exceptions
Queue::setOnError(?callable $cb)/getOnError()— an opt-in callback invoked for every caught throwable, with signaturefn(?Job $job, \Throwable $e, int $attempts, bool $willRetry): void. It fires for both intermediate retries ($willRetry = true) and terminal failures ($willRetry = false).getFailReason()includes the exception class in addition to the message.Job) payloads are reported to the callback as terminal failures with anulljob (and still marked failed).QueueFacade::setOnError()passthrough.#6 — standardize README
setOnError(an "Observing Failures" section) and added it to the API table.getFailed()returnsQueuedJob[], soretry($failed[0]->getId()), not array access).How to Test / Verify
composer test→ 38 tests pass (was 33; +5 new covering: onError on terminal failure, intermediate retry, invalid payload, chainability/getter, facade passthrough). Two existing tests updated for the enrichedfailReasonformat.php -l.composer fix-csclean.Breaking Changes and Migration Steps
None. The callback is opt-in. The only observable change is that a failed job's
getFailReason()now includes the exception class prefix (e.g.RuntimeException: ...) in addition to the message.Checklist
composer fix-cs)Related issues
Closes #9, Closes #6