mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
b12a00c391
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73509 467b73ca-7a2a-4603-9d3b-597d59a354a9
32 lines
719 B
PHP
32 lines
719 B
PHP
<?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.
|
|
*
|
|
* @package sapphire
|
|
* @subpackage validation
|
|
*/
|
|
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;
|
|
}
|
|
}
|
|
?>
|