Collect step args validation errors

[MAILPOET-4659]
This commit is contained in:
Jan Jakes
2022-10-03 15:52:22 +02:00
committed by Jan Jakeš
parent a41445cdaa
commit 9da204489d
2 changed files with 28 additions and 0 deletions

View File

@@ -27,6 +27,7 @@ class Exceptions {
private const WORKFLOW_STRUCTURE_MODIFICATION_NOT_SUPPORTED = 'mailpoet_automation_workflow_structure_modification_not_supported';
private const WORKFLOW_STRUCTURE_NOT_VALID = 'mailpoet_automation_workflow_structure_not_valid';
private const WORKFLOW_STEP_MODIFIED_WHEN_UNKNOWN = 'mailpoet_automation_workflow_step_modified_when_unknown';
private const WORKFLOW_NOT_VALID = 'mailpoet_automation_workflow_not_valid';
public function __construct() {
throw new InvalidStateException(
@@ -180,4 +181,12 @@ class Exceptions {
)
);
}
public static function workflowNotValid(string $detail, array $errors): UnexpectedValueException {
return UnexpectedValueException::create()
->withErrorCode(self::WORKFLOW_NOT_VALID)
// translators: %s is a detailed information
->withMessage(sprintf(__("Workflow validation failed: %s", 'mailpoet'), $detail))
->withErrors($errors);
}
}