Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 * This file is part of the Mink package.
|
Chris@0
|
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
|
Chris@0
|
6 *
|
Chris@0
|
7 * For the full copyright and license information, please view the LICENSE
|
Chris@0
|
8 * file that was distributed with this source code.
|
Chris@0
|
9 */
|
Chris@0
|
10
|
Chris@0
|
11 namespace Behat\Mink\Exception;
|
Chris@0
|
12
|
Chris@0
|
13 @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
|
14
|
Chris@0
|
15 use Behat\Mink\Element\Element;
|
Chris@0
|
16
|
Chris@0
|
17 /**
|
Chris@0
|
18 * A standard way for elements to re-throw exceptions.
|
Chris@0
|
19 *
|
Chris@0
|
20 * @deprecated This exception class is not used anymore in Mink 1.6 and will be removed in 2.0
|
Chris@0
|
21 *
|
Chris@0
|
22 * @author Chris Worfolk <xmeltrut@gmail.com>
|
Chris@0
|
23 */
|
Chris@0
|
24 class ElementException extends Exception
|
Chris@0
|
25 {
|
Chris@0
|
26 private $element;
|
Chris@0
|
27
|
Chris@0
|
28 /**
|
Chris@0
|
29 * Initialises exception.
|
Chris@0
|
30 *
|
Chris@0
|
31 * @param Element $element optional message
|
Chris@0
|
32 * @param \Exception $exception exception
|
Chris@0
|
33 */
|
Chris@0
|
34 public function __construct(Element $element, \Exception $exception)
|
Chris@0
|
35 {
|
Chris@0
|
36 $this->element = $element;
|
Chris@0
|
37
|
Chris@0
|
38 parent::__construct(sprintf("Exception thrown by %s\n%s", $element->getXpath(), $exception->getMessage()));
|
Chris@0
|
39 }
|
Chris@0
|
40
|
Chris@0
|
41 /**
|
Chris@0
|
42 * Override default toString so we don't send a full backtrace in verbose mode.
|
Chris@0
|
43 *
|
Chris@0
|
44 * @return string
|
Chris@0
|
45 */
|
Chris@0
|
46 public function __toString()
|
Chris@0
|
47 {
|
Chris@0
|
48 return $this->getMessage();
|
Chris@0
|
49 }
|
Chris@0
|
50
|
Chris@0
|
51 /**
|
Chris@0
|
52 * Get the element that caused the exception.
|
Chris@0
|
53 *
|
Chris@0
|
54 * @return Element
|
Chris@0
|
55 */
|
Chris@0
|
56 public function getElement()
|
Chris@0
|
57 {
|
Chris@0
|
58 return $this->element;
|
Chris@0
|
59 }
|
Chris@0
|
60 }
|