@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorApplicationTransactionValidationException
4 extends Exception {
5
6 private $errors;
7
8 /**
9 * @param array<PhabricatorApplicationTransactionValidationError> $errors
10 */
11 public function __construct(array $errors) {
12 assert_instances_of(
13 $errors,
14 PhabricatorApplicationTransactionValidationError::class);
15
16 $this->errors = $errors;
17
18 $message = array();
19 $message[] = pht('Validation errors:');
20 foreach ($this->errors as $error) {
21 $message[] = ' - '.$error->getMessage();
22 }
23
24 parent::__construct(implode("\n", $message));
25 }
26
27 public function getErrors() {
28 return $this->errors;
29 }
30
31 public function getErrorMessages() {
32 return mpull($this->errors, 'getMessage');
33 }
34
35 public function getShortMessage($type) {
36 foreach ($this->errors as $error) {
37 if ($error->getType() === $type) {
38 if ($error->getShortMessage() !== null) {
39 return $error->getShortMessage();
40 }
41 }
42 }
43 return null;
44 }
45
46}