Use Throwable instead of \Exception
[MAILPOET-4463]
This commit is contained in:
committed by
Jan Jakeš
parent
2c2f15a562
commit
8cbbe5aa6e
@ -124,14 +124,14 @@ class StepHandler {
|
|||||||
try {
|
try {
|
||||||
$this->stepRunners[$stepType]->run($step, $workflow, $workflowRun);
|
$this->stepRunners[$stepType]->run($step, $workflow, $workflowRun);
|
||||||
$log->markCompletedSuccessfully();
|
$log->markCompletedSuccessfully();
|
||||||
} catch (\Exception $e) {
|
} catch (Throwable $e) {
|
||||||
$log->markFailed();
|
$log->markFailed();
|
||||||
$log->addError($e);
|
$log->addError($e);
|
||||||
throw $e;
|
throw $e;
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
$this->hooks->doWorkflowStepAfterRun($log);
|
$this->hooks->doWorkflowStepAfterRun($log);
|
||||||
} catch (Exception $e) {
|
} catch (Throwable $e) {
|
||||||
$log->addError($e);
|
$log->addError($e);
|
||||||
}
|
}
|
||||||
$this->workflowRunLogStorage->createWorkflowRunLog($log);
|
$this->workflowRunLogStorage->createWorkflowRunLog($log);
|
||||||
|
@ -4,6 +4,7 @@ namespace MailPoet\Automation\Engine\Data;
|
|||||||
|
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use MailPoet\Automation\Engine\Utils\Json;
|
use MailPoet\Automation\Engine\Utils\Json;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
class WorkflowRunLog {
|
class WorkflowRunLog {
|
||||||
|
|
||||||
@ -131,13 +132,13 @@ class WorkflowRunLog {
|
|||||||
$this->completedAt = new DateTimeImmutable();
|
$this->completedAt = new DateTimeImmutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addError(\Exception $exception, string $userFacingMessage = ''): void {
|
public function addError(Throwable $error, string $userFacingMessage = ''): void {
|
||||||
$error = [
|
$error = [
|
||||||
'message' => $exception->getMessage(),
|
'message' => $error->getMessage(),
|
||||||
'exceptionClass' => get_class($exception),
|
'errorClass' => get_class($error),
|
||||||
'userFacingMessage' => $userFacingMessage,
|
'userFacingMessage' => $userFacingMessage,
|
||||||
'code' => $exception->getCode(),
|
'code' => $error->getCode(),
|
||||||
'trace' => $exception->getTrace(),
|
'trace' => $error->getTrace(),
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->errors[] = $error;
|
$this->errors[] = $error;
|
||||||
|
@ -143,7 +143,7 @@ class WorkflowRunLogTest extends \MailPoetTest {
|
|||||||
$error = $log->getErrors()[0];
|
$error = $log->getErrors()[0];
|
||||||
expect($error['message'])->equals('error');
|
expect($error['message'])->equals('error');
|
||||||
expect($error['code'])->equals(12345);
|
expect($error['code'])->equals(12345);
|
||||||
expect($error['exceptionClass'])->equals('Exception');
|
expect($error['errorClass'])->equals('Exception');
|
||||||
expect($error['trace'])->array();
|
expect($error['trace'])->array();
|
||||||
expect(count($error['trace']))->greaterThan(0);
|
expect(count($error['trace']))->greaterThan(0);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user