1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-24 15:52:41 +01:00
phorge-phorge/src/applications/transactions/exception/PhabricatorApplicationTransactionValidationException.php
Joshua Spence 36e2d02d6e phtize all the things
Summary: `pht`ize a whole bunch of strings in rP.

Test Plan: Intense eyeballing.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: hach-que, Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D12797
2015-05-22 21:16:39 +10:00

43 lines
930 B
PHP

<?php
final class PhabricatorApplicationTransactionValidationException
extends Exception {
private $errors;
public function __construct(array $errors) {
assert_instances_of(
$errors,
'PhabricatorApplicationTransactionValidationError');
$this->errors = $errors;
$message = array();
$message[] = pht('Validation errors:');
foreach ($this->errors as $error) {
$message[] = ' - '.$error->getMessage();
}
parent::__construct(implode("\n", $message));
}
public function getErrors() {
return $this->errors;
}
public function getErrorMessages() {
return mpull($this->errors, 'getMessage');
}
public function getShortMessage($type) {
foreach ($this->errors as $error) {
if ($error->getType() === $type) {
if ($error->getShortMessage() !== null) {
return $error->getShortMessage();
}
}
}
return null;
}
}