The PHP docs are a bit fuzzy on this one, so I'm asking it here. Given this worker code:

<?php
$gmworker= new GearmanWorker();
$gmworker->addServer();
$gmworker->addFunction("doSomething", "doSomethingFunc");
while($gmworker->work());

function doSomethingFunc()
{
    try {
        $value = doSomethingElse($job->workload());
    } catch (Exception $e) {
        // Need to notify the client of the error
    }

    return $value;
}

What's the proper way to notify the client of any error that took place? Return false? Use GearmanJob::sendFail()? If it's the latter, do I need to return from my doSomethingFunc() after calling sendFail()? Should the return value be whatever sendFail() returns?

The client is using GearmanClient::returnCode() to check for failures. Additionally, simply using "return $value" seems to work, but should I be using GearmanJob::sendData() or GearmanJob::sendComplete() instead?

Edit
Report