This commit is contained in:
Yuri Kuznetsov
2021-05-20 12:28:00 +03:00
parent 29d1cda756
commit ee24b58a2c
2 changed files with 15 additions and 2 deletions
@@ -87,7 +87,13 @@ class RunJob implements Command
$this->jobManager->runJob($job);
}
catch (Throwable $e) {
$io->writeLine("Error: Job '{$jobName}' failed to execute.");
$message = "Error: Job '{$jobName}' failed to execute.";
if ($e->getMessage()) {
$message .= ' ' . $e->getMessage();
}
$io->writeLine($message);
return;
}
+8 -1
View File
@@ -165,7 +165,7 @@ class JobRunner
$this->entityManager->saveEntity($job);
if ($throwException && $exception) {
throw new $exception;
throw new $exception($exception->getMessage());
}
if ($job->getScheduledJobId() && !$skipLog) {
@@ -186,6 +186,13 @@ class JobRunner
$obj = $this->jobFactory->create($jobName);
if ($obj instanceof JobTargeted) {
if (
$job->getTargetType() === null ||
$job->getTargetId() === null
) {
throw new Error("Can't run targeted job '{$jobName}' w/o target.");
}
$obj->run($job->getTargetType(), $job->getTargetId(), $job->getData());
return;