2008-10-08 22:42:09 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Exception thrown by {@link DataObject}::write if validation fails. By throwing an
|
|
|
|
* exception rather than a user error, the exception can be caught in unit tests and as such
|
|
|
|
* can be used as a successful test.
|
2009-03-22 23:59:14 +01:00
|
|
|
*
|
2012-04-12 08:02:46 +02:00
|
|
|
* @package framework
|
2009-03-22 23:59:14 +01:00
|
|
|
* @subpackage validation
|
2008-10-08 22:42:09 +02:00
|
|
|
*/
|
|
|
|
class ValidationException extends Exception {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var {@link ValidationResult} or string
|
|
|
|
*/
|
|
|
|
protected $result;
|
|
|
|
|
|
|
|
public function __construct($result = null, $message = null, $code = 0) {
|
|
|
|
if($result instanceof ValidationResult) {
|
|
|
|
$this->result = $result;
|
|
|
|
} else {
|
|
|
|
$code = $message;
|
|
|
|
$message = $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
parent::__construct($message, $code);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getResult() {
|
|
|
|
return $this->result;
|
|
|
|
}
|
|
|
|
}
|