* @package generis */ class common_exception_ValidationFailed extends common_exception_BadRequest { /** * Name of the failed field. * * @var string */ private $field; /** * common_exception_ValidationFailed constructor. * * @param string $field * @param string|null $message * @param int $code */ public function __construct($field, $message = null, $code = 0) { $this->field = $field; if (!$message) { $message = sprintf("Validation for field '%s' has failed.", $field); } parent::__construct($message, $code); } /** * @return string */ public function getField() { return $this->field; } /** * @return string */ public function getUserMessage() { return __("Validation for field '%s' has failed.", $this->field); } }