Skip to content
Snippets Groups Projects

Issue #3268612: StageValidationException does not provide a message based on validation results

Merged Issue #3268612: StageValidationException does not provide a message based on validation results
1 unresolved thread
1 unresolved thread

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
21 21 *
22 22 * @param \Drupal\package_manager\ValidationResult[] $results
23 23 * Any relevant validation results.
24 * @param string $message
25 * (optional) The exception message. Defaults to a plain text representation
26 * of the validation results.
24 27 * @param mixed ...$arguments
25 * Arguments to pass to the parent constructor.
28 * Additional arguments to pass to the parent constructor.
26 29 */
27 public function __construct(array $results = [], ...$arguments) {
30 public function __construct(array $results = [], string $message = '', ...$arguments) {
28 31 $this->results = $results;
29 parent::__construct(...$arguments);
32 parent::__construct($message ?: $this->getResultsAsText(), ...$arguments);
  • Could we actually send $message to $this->getResultsAsText() and use it as the start of the message if set.

    For example in Updater.php we have

    catch (StageValidationException $e) {
      throw new UpdateException($e->getResults(), $e->getMessage() ?: "Unable to complete the update because of errors.", $e->getCode(), $e);
    }

    Since UpdateException extends StageValidationException for the example above $updater_exception->getMessage() will always return "Unable to complete the update because of errors." and never contain the results. So this issue would not help any of the exceptions thrown here.

  • Author Maintainer

    Sure, we could do that, but refactoring this exception is tricky because of the major knock-on effect it has on the tests.

    Here's my suggestion: in this issue, let's change Updater::dispatch() so that it removes the default message it passes to UpdateException. That should be a simpler fix. Maybe in a follow-up we could properly implement the ability to have a bit of preamble text before the results, since that is useful but not quite as urgent for DrupalCon.

  • Please register or sign in to reply
  • merged

  • Please register or sign in to reply
    Loading