validate( $value ); } // All successful } catch (ValidationException $e) { // Add the friendly name of the variable that failed validation, and rethrow the exception // for the calling code to catch $e->append_name($name); throw $e; } } }; /* * Validation Exceptions */ class ValidationException extends BaseException { public function __construct($message) { parent::__construct($message); } public function append_name($name) { $this->e .= ", while validating '{$name}'."; } }; ?>