/** * @param Task\TaskInterface $task * @return Task\Result|null */ public function checkProcessing(Task\TaskInterface $task) { $client = $this->getClient(); try { $job = $client->fetchJob(array('job_id' => $task->getProcessId())); } catch (ClientException\ServerException $e) { // The request couldn't be processed (e.g. network problems, performance issues, 5xx problems, etc.) // It's possible, the processing can be started successfully upon retry. throw new Exception\ProcessingUnavailableException(sprintf('Failed to check processing because DWS FileConversion seems to be unavailable: %s', $e->getMessage()), 0, $e); } catch (ClientException\ClientException $e) { // Invalid job or 4xx problems. // Retrying won't change anything, so we need to fail... throw new Exception\ProcessingFailedException(sprintf('Processing failed after checking the job: %s', $e->getMessage()), 0, $e); } catch (\Exception $e) { // Also fail when something else went wrong... throw new Exception\ProcessingFailedException(sprintf('Failed to check processing: %s', $e->getMessage()), 1, $e); } // End directly when job is in a final state if (in_array($job->getStatus(), array('complete', 'error'))) { return $this->endProcessing($task, $job); } return null; }
/** * @param Task\TaskInterface $task * @return Task\Result|null */ public function checkProcessing(Task\TaskInterface $task) { $client = $this->getClient(); try { $response = $client->pollJob(array('job_id' => $task->getProcessId())); } catch (BlitlineException\ServerException $e) { // The request couldn't be processed (e.g. network problems, performance issues, 5xx problems, etc.) // It's possible, the processing can be started successfully upon retry. throw new Exception\ProcessingUnavailableException(sprintf('Failed to check processing because Blitline seems to be unavailable: %s', $e->getMessage()), 0, $e); } catch (BlitlineException\ClientException $e) { // Invalid job or 4xx problems. // Retrying won't change anything, so we need to fail... throw new Exception\ProcessingFailedException(sprintf('Processing failed after polling for the completion of the job: %s', $e->getMessage()), 0, $e); } catch (\Exception $e) { // Also fail when something else went wrong... throw new Exception\ProcessingFailedException(sprintf('Failed to check processing: %s', $e->getMessage()), 1, $e); } return $this->endProcessing($task, $response); }