[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/transactions/exception/ -> PhabricatorApplicationTransactionValidationException.php (source)

   1  <?php
   2  
   3  final class PhabricatorApplicationTransactionValidationException
   4    extends Exception {
   5  
   6    private $errors;
   7  
   8    public function __construct(array $errors) {
   9      assert_instances_of(
  10        $errors,
  11        'PhabricatorApplicationTransactionValidationError');
  12  
  13      $this->errors = $errors;
  14  
  15      $message = array();
  16      $message[] = 'Validation errors:';
  17      foreach ($this->errors as $error) {
  18        $message[] = '  - '.$error->getMessage();
  19      }
  20  
  21      parent::__construct(implode("\n", $message));
  22    }
  23  
  24    public function getErrors() {
  25      return $this->errors;
  26    }
  27  
  28    public function getErrorMessages() {
  29      return mpull($this->errors, 'getMessage');
  30    }
  31  
  32    public function getShortMessage($type) {
  33      foreach ($this->errors as $error) {
  34        if ($error->getType() === $type) {
  35          if ($error->getShortMessage() !== null) {
  36            return $error->getShortMessage();
  37          }
  38        }
  39      }
  40      return null;
  41    }
  42  
  43  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1