comparison vendor/behat/mink/src/Exception/ElementException.php @ 0:4c8ae668cc8c

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