News Feed
Jobs Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Vance Lucas:
Handling Exceptions in Gearman Tasks (Even Background Ones)
August 03, 2012 @ 08:28:25

Vance Lucas has a quick new post to his site showing you how to handle exceptions in Gearman tasks so that they can be logged correctly as a failure.

I recently had some issues with Gearman tasks throwing exceptions and killing the whole Gearman daemon. This made it nearly impossible to trace errors back to their origin, because the logged exception stack trace didn't provide much useful information, because it just logged where it failed in Gearman. [...] The only other place to add code that will catch exceptions for all jobs run is in the GearmanWorker::addFunction method.

To solve the issue, he ends up passing in a closure that takes in the $task and wraps its execution in a try/catch to handle the exception correctly. This is then thrown to a custom exception handler and logged for future diagnosis.

0 comments voice your opinion now!
gearman exception handling try catch closure


blog comments powered by Disqus

Similar Posts

DevShed: Displaying Meaningful Error Messages when Auto Loading Classes in PHP 5

Gonzalo Ayuso's Blog: Database connection pooling with PHP and gearman

Alexander Netkachev's Blog: PHP coding tip: Convert notices and warnings into Exceptions

Chris Hartjes: Testing Smells - Try/catch

Vance Lucas' Blog: Practical Uses for PHP 5.3 Closures


Community Events











Don't see your event here?
Let us know!


release component code security install symfony2 support hhvm facebook overview application unittest podcast opinion introduction package composer language hack framework

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework