From 717b8fce831a4da26b886741afe3385b53db8c95 Mon Sep 17 00:00:00 2001 From: rettal Date: Fri, 24 Sep 2010 12:21:13 -0700 Subject: [PATCH 1/2] Added new exception support to Zend\Dom --- src/Query.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Query.php b/src/Query.php index 3b9f4e6..e8b5f5d 100644 --- a/src/Query.php +++ b/src/Query.php @@ -190,7 +190,7 @@ public function execute($query) public function queryXpath($xpathQuery, $query = null) { if (null === ($document = $this->getDocument())) { - throw new Exception('Cannot query; no document registered'); + throw new RuntimeException('Cannot query; no document registered'); } libxml_use_internal_errors(true); @@ -214,7 +214,7 @@ public function queryXpath($xpathQuery, $query = null) libxml_use_internal_errors(false); if (!$success) { - throw new Exception(sprintf('Error parsing document (type == %s)', $type)); + throw new RuntimeException(sprintf('Error parsing document (type == %s)', $type)); } $nodeList = $this->_getNodeList($domDoc, $xpathQuery); @@ -248,4 +248,4 @@ protected function _getNodeList($document, $xpathQuery) $xpathQuery = (string) $xpathQuery; return $xpath->query($xpathQuery); } -} +} \ No newline at end of file From 499e6b476bd6db7957631b6361591e127e255910 Mon Sep 17 00:00:00 2001 From: Ralph Schindler Date: Thu, 30 Sep 2010 15:16:42 -0500 Subject: [PATCH 2/2] Milestone/Exceptions - merged in rettal's Zend\Dom refactoring - moved the RuntimeException to Exception namespace --- src/Exception/RuntimeException.php | 38 ++++++++++++++++++++++++++++++ src/Query.php | 4 ++-- test/QueryTest.php | 2 +- 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 src/Exception/RuntimeException.php diff --git a/src/Exception/RuntimeException.php b/src/Exception/RuntimeException.php new file mode 100644 index 0000000..64ef933 --- /dev/null +++ b/src/Exception/RuntimeException.php @@ -0,0 +1,38 @@ +getDocument())) { - throw new RuntimeException('Cannot query; no document registered'); + throw new Exception\RuntimeException('Cannot query; no document registered'); } libxml_use_internal_errors(true); @@ -214,7 +214,7 @@ public function queryXpath($xpathQuery, $query = null) libxml_use_internal_errors(false); if (!$success) { - throw new RuntimeException(sprintf('Error parsing document (type == %s)', $type)); + throw new Exception\RuntimeException(sprintf('Error parsing document (type == %s)', $type)); } $nodeList = $this->_getNodeList($domDoc, $xpathQuery); diff --git a/test/QueryTest.php b/test/QueryTest.php index f9f9105..a4b128e 100644 --- a/test/QueryTest.php +++ b/test/QueryTest.php @@ -127,7 +127,7 @@ public function testDocumentTypeShouldBeAutomaticallyDiscovered() public function testQueryingWithoutRegisteringDocumentShouldThrowException() { - $this->setExpectedException('\\Zend\\Dom\\Exception', 'no document'); + $this->setExpectedException('\Zend\Dom\Exception\RuntimeException', 'no document'); $this->query->execute('.foo'); }