|
12 | 12 |
|
13 | 13 | namespace Derafu\Xml\Exception; |
14 | 14 |
|
| 15 | +use Derafu\Xml\Contract\XmlDocumentInterface; |
| 16 | +use Throwable; |
| 17 | + |
15 | 18 | /** |
16 | 19 | * Exception thrown when an XPath query fails. |
17 | 20 | * |
|
22 | 25 | */ |
23 | 26 | class XmlQueryException extends XmlException |
24 | 27 | { |
| 28 | + /** |
| 29 | + * Constructor of the exception. |
| 30 | + * |
| 31 | + * @param string $message The exception message. |
| 32 | + * @param array $errors The array with the errors. |
| 33 | + * @param int $code The exception code (optional). |
| 34 | + * @param Throwable|null $previous The previous exception (optional). |
| 35 | + * @param XmlDocumentInterface|null $xmlDocument The XML document that |
| 36 | + * caused the exception or `null` if it is not present. |
| 37 | + * @param string|null $xpathExpression The XPath expression that caused the |
| 38 | + * exception or `null` if it is not present. |
| 39 | + */ |
| 40 | + public function __construct( |
| 41 | + string $message, |
| 42 | + array $errors = [], |
| 43 | + int $code = 0, |
| 44 | + ?Throwable $previous = null, |
| 45 | + ?XmlDocumentInterface $xmlDocument = null, |
| 46 | + private ?string $xpathExpression = null, |
| 47 | + ) { |
| 48 | + parent::__construct($message, $errors, $code, $previous, $xmlDocument); |
| 49 | + } |
| 50 | + |
| 51 | + /** |
| 52 | + * Gets the XPath expression that caused the exception. |
| 53 | + * |
| 54 | + * @return string|null The XPath expression that caused the exception or |
| 55 | + * `null` if it is not present. |
| 56 | + */ |
| 57 | + public function getXpathExpression(): ?string |
| 58 | + { |
| 59 | + return $this->xpathExpression; |
| 60 | + } |
25 | 61 | } |
0 commit comments