for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Spiral\Queue\Interceptor\Consume;
use Spiral\Core\CoreInterceptorInterface;
use Spiral\Core\CoreInterface;
use Spiral\Queue\Exception\StateException;
use Spiral\Queue\Failed\FailedJobHandlerInterface;
final class ErrorHandlerInterceptor implements CoreInterceptorInterface
{
public function __construct(
private readonly FailedJobHandlerInterface $handler
) {
}
/** @psalm-suppress ParamNameMismatch */
public function process(string $name, string $action, array $parameters, CoreInterface $core): mixed
try {
return $core->callAction($name, $action, $parameters);
} catch (\Throwable $e) {
if (!$e instanceof StateException) {
$this->handler->handle(
$parameters['driver'],
$parameters['queue'],
$name,
$parameters['payload'],
$e
);
throw $e;