Skip to main content
Version: 2024.3

Extended Error Handling

Handling exceptions during execution

To make sure the job execution engine does not retry failed messages you should use the provided functionality from the AbstractAutomationActionHandler to handle exceptions as a top level exception handler.

This will make sure that no unexpected exceptions are thrown without being caught and handled properly.

    class VariantGeneratorHandler extends AbstractAutomationActionHandler
{
...
protected function doInvoke(JobExecutionEngineMessageInterface $message){
...
try {
...
} catch (Exception $exception) {
$this->throwUnRecoverableException($exception);
}
}
}

Abort the current action

To abort the current action you can use the abortAction method from the AbstractAutomationActionHandler. You can provide additional information to the error message as well as the translation domain, thus making the error message configurable and translatable.

With the 4th parameter of the abortAction method you can define the exception class that should be thrown.

    class VariantGeneratorHandler extends AbstractAutomationActionHandler
{
...
protected function doInvoke(JobExecutionEngineMessageInterface $message){
...
if ($validationFailed) {
$this->abortAction(
'pimcore_copilot_general_error_invalid_template',
[
'%template%' => $this->payload,
'%error%' => $e->getMessage(),
],
PimcoreCopilotBundle::TRANSLATION_DOMAIN,
RuntimeException::class
);
}
}
}
caution

Aborting the current action will stop the execution of the current action only, that doesn't necessarily mean the whole job will be stopped. Copilot is based on the Generic Execution Engine, which has its own error handling strategy based on its configuration.

If you want to read more about the error handling strategy of the Generic Execution Engine, please refer to the Generic Execution Engine documentation.

Error logs

There are different logs available:

Job Run Log File

The pimcore_copilot.log file contains all the logs from the automation actions and more detailed information. It can be found in the var/logs directory of your Pimcore installation.

Job Run UI

The Job Run UI provides a detailed view of the job run and its steps. It also contains the log of the job run. You need the pcp_job_run_permission to access the Job Run UI.

API

The API provides a way to access the logs of the job runs. You can use the JobRun entity to access the log.

$jobRun = $jobRunRepository->find($jobRunId);
$log = $jobRun->getLog();

Events

Since Copilot bundle is based on the Generic Execution Engine, you can use the events provided by the Generic Execution Engine to react to changes in the state of a job run. Please have a look at the Generic Execution Engine documentation for more information.