Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Behat\Mink\Exception; Chris@0: Chris@0: @trigger_error('The class '.__NAMESPACE__.'\ElementException is deprecated as of Mink 1.6 and will be removed in 2.0', E_USER_DEPRECATED); Chris@0: Chris@0: use Behat\Mink\Element\Element; Chris@0: Chris@0: /** Chris@0: * A standard way for elements to re-throw exceptions. Chris@0: * Chris@0: * @deprecated This exception class is not used anymore in Mink 1.6 and will be removed in 2.0 Chris@0: * Chris@0: * @author Chris Worfolk Chris@0: */ Chris@0: class ElementException extends Exception Chris@0: { Chris@0: private $element; Chris@0: Chris@0: /** Chris@0: * Initialises exception. Chris@0: * Chris@0: * @param Element $element optional message Chris@0: * @param \Exception $exception exception Chris@0: */ Chris@0: public function __construct(Element $element, \Exception $exception) Chris@0: { Chris@0: $this->element = $element; Chris@0: Chris@0: parent::__construct(sprintf("Exception thrown by %s\n%s", $element->getXpath(), $exception->getMessage())); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Override default toString so we don't send a full backtrace in verbose mode. Chris@0: * Chris@0: * @return string Chris@0: */ Chris@0: public function __toString() Chris@0: { Chris@0: return $this->getMessage(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get the element that caused the exception. Chris@0: * Chris@0: * @return Element Chris@0: */ Chris@0: public function getElement() Chris@0: { Chris@0: return $this->element; Chris@0: } Chris@0: }