Error handling.
authorGunnar Wrobel <p@rdus.de>
Mon, 29 Jun 2009 05:55:55 +0000 (07:55 +0200)
committerGunnar Wrobel <p@rdus.de>
Mon, 29 Jun 2009 05:55:55 +0000 (07:55 +0200)
13 files changed:
framework/Kolab_Format/lib/Horde/Kolab/Format.php
framework/Kolab_Format/lib/Horde/Kolab/Format/XML.php
framework/Kolab_Format/lib/Horde/Kolab/Format/XML/Annotation.php
framework/Kolab_Format/lib/Horde/Kolab/Format/XML/Contact.php
framework/Kolab_Format/lib/Horde/Kolab/Format/XML/Distributionlist.php
framework/Kolab_Format/lib/Horde/Kolab/Format/XML/Event.php
framework/Kolab_Format/lib/Horde/Kolab/Format/XML/Hprefs.php
framework/Kolab_Format/lib/Horde/Kolab/Format/XML/Note.php
framework/Kolab_Format/lib/Horde/Kolab/Format/XML/Task.php
framework/Kolab_Format/test/Horde/Kolab/Format/ContactTest.php
framework/Kolab_Format/test/Horde/Kolab/Format/EventTest.php
framework/Kolab_Format/test/Horde/Kolab/Format/PreferencesTest.php
framework/Kolab_Format/test/Horde/Kolab/Format/RecurrenceTest.php

index 98fc90d..37dc3f4 100644 (file)
@@ -47,8 +47,7 @@ abstract class Horde_Kolab_Format
      *
      *                                    'version' - The format version.
      *
-     * @return mixed    The newly created concrete Horde_Kolab_Format_XML instance, or
-     *                  a PEAR error.
+     * @return mixed    The newly created concrete Horde_Kolab_Format_XML instance
      *
      * @throws Horde_Exception If the specified driver could not be loaded.
      */
index 080d161..5297eae 100644 (file)
@@ -364,9 +364,11 @@ class Horde_Kolab_Format_XML
      * @param string    $object_type The object type that should be handled.
      * @param array     $params      Any additional parameters.
      *
-     * @return Horde_Kolab_Format_XML|PEAR_Error The newly created concrete
-     *                                           Horde_Kolab_Format_XML
-     *                                           instance.
+     * @return Horde_Kolab_Format_XML The newly created concrete
+     *                                Horde_Kolab_Format_XML instance.
+     *
+     * @throws Horde_Exception If the class for the object type could
+     *                         not be loaded.
      */
     public function &factory($object_type = '', $params = null)
     {
@@ -476,7 +478,7 @@ class Horde_Kolab_Format_XML
      *
      * @param array $children An array of XML nodes.
      *
-     * @return array|PEAR_Error The data array representing the object.
+     * @return array The data array representing the object.
      *
      * @throws Horde_Exception If parsing the XML data failed.
      */
index ced6102..61a14b5 100644 (file)
@@ -71,9 +71,6 @@ class Horde_Kolab_Format_XML_Annotation extends Horde_Kolab_Format_XML
     protected function _load(&$children)
     {
         $object = $this->_loadArray($children, $this->_fields_specific);
-        if (is_a($object, 'PEAR_Error')) {
-            return $object;
-        }
 
         $result = array();
         foreach ($object['annotation'] as $annotation) {
index 6be0db1..44f4783 100644 (file)
@@ -313,9 +313,6 @@ class Horde_Kolab_Format_XML_Contact extends Horde_Kolab_Format_XML
     protected function _load(&$children)
     {
         $object = $this->_loadArray($children, $this->_fields_specific);
-        if (is_a($object, 'PEAR_Error')) {
-            return $object;
-        }
 
         // Handle name fields
         if (isset($object['name'])) {
index 47c60ab..0e78468 100644 (file)
@@ -73,9 +73,6 @@ class Horde_Kolab_Format_XML_Distributionlist extends Horde_Kolab_Format_XML
     protected function _load(&$children)
     {
         $object = $this->_loadArray($children, $this->_fields_specific);
-        if (is_a($object, 'PEAR_Error')) {
-            return $object;
-        }
 
         // Map the display-name of a kolab dist list to horde's lastname attribute
         if (isset($object['display-name'])) {
index ab6261d..63b5df7 100644 (file)
@@ -100,9 +100,6 @@ class Horde_Kolab_Format_XML_Event extends Horde_Kolab_Format_XML
     protected function _load(&$children)
     {
         $object = parent::_load($children);
-        if (is_a($object, 'PEAR_Error')) {
-            return $object;
-        }
 
         // Translate start/end date including full day events
         if (strlen($object['start-date']) == 10) {
index d51f795..8f63c71 100644 (file)
@@ -87,7 +87,7 @@ class Horde_Kolab_Format_XML_Hprefs extends Horde_Kolab_Format_XML
                 $object['application'] = $object['categories'];
                 unset($object['categories']);
             } else {
-                return PEAR::raiseError('Preferences XML object is missing an application setting.');
+                throw new Horde_Exception('Preferences XML object is missing an application setting.');
             }
         }
 
@@ -110,7 +110,7 @@ class Horde_Kolab_Format_XML_Hprefs extends Horde_Kolab_Format_XML
                 $object['application'] = $object['categories'];
                 unset($object['categories']);
             } else {
-                return PEAR::raiseError('Preferences XML object is missing an application setting.');
+                throw new Horde_Exception('Preferences XML object is missing an application setting.');
             }
         }
 
index a8e986d..c15bb64 100644 (file)
@@ -79,9 +79,6 @@ class Horde_Kolab_Format_XML_Note extends Horde_Kolab_Format_XML
     protected function _load(&$children)
     {
         $object = $this->_loadArray($children, $this->_fields_specific);
-        if (is_a($object, 'PEAR_Error')) {
-            return $object;
-        }
 
         $object['desc'] = $object['summary'];
         unset($object['summary']);
index 748167e..48bb5bf 100644 (file)
@@ -124,9 +124,6 @@ class Horde_Kolab_Format_XML_Task extends Horde_Kolab_Format_XML
     protected function _load(&$children)
     {
         $object = $this->_loadArray($children, $this->_fields_specific);
-        if (is_a($object, 'PEAR_Error')) {
-            return $object;
-        }
 
         $object['name'] = $object['summary'];
         unset($object['summary']);
index a1ac229..3ebde17 100644 (file)
@@ -82,9 +82,6 @@ class Horde_Kolab_Format_ContactTest extends PHPUnit_Framework_TestCase
                         'full-name' => 'User Name',
                         'email' => 'user@example.org');
         $xml = $contact->save($object);
-        if (is_a($xml, 'PEAR_Error')) {
-            $this->assertEquals('', $xml->getMessage());
-        }
         $expect = file_get_contents(dirname(__FILE__) . '/fixtures/contact_mail.xml');
         $this->assertEquals($expect, $xml);
     }
@@ -100,9 +97,6 @@ class Horde_Kolab_Format_ContactTest extends PHPUnit_Framework_TestCase
                         'pgp-publickey' => 'PGP Test Key',
                         'email' => 'user@example.org');
         $xml = $contact->save($object);
-        if (is_a($xml, 'PEAR_Error')) {
-            $this->assertEquals('', $xml->getMessage());
-        }
         $expect = file_get_contents(dirname(__FILE__) . '/fixtures/contact_pgp.xml');
         $this->assertEquals($expect, $xml);
     }
@@ -117,16 +111,10 @@ class Horde_Kolab_Format_ContactTest extends PHPUnit_Framework_TestCase
         $contact = &new Horde_Kolab_Format_XML_contact();
         $xml = file_get_contents(dirname(__FILE__) . '/fixtures/contact_category.xml');
         $object = $contact->load($xml);
-        if (is_a($object, 'PEAR_Error')) {
-            $this->assertEquals('', $object->getMessage());
-        }
         $this->assertContains('Test', $object['categories']);
 
         $prefs = 'some string';
         $object = $contact->load($xml);
-        if (is_a($object, 'PEAR_Error')) {
-            $this->assertEquals('', $object->getMessage());
-        }
         $this->assertContains('Test', $object['categories']);
     }
 
@@ -150,9 +138,6 @@ class Horde_Kolab_Format_ContactTest extends PHPUnit_Framework_TestCase
             $xml = file_get_contents(dirname(__FILE__) . '/fixtures/contact_category.xml');
 
             $object = $contact->load($xml);
-            if (is_a($object, 'PEAR_Error')) {
-                $this->assertEquals('', $object->getMessage());
-            }
             $this->assertContains('Test', $object['categories']);
             $this->assertEquals('Test', $prefs->getValue('categories'));
         }
index 03ddb8d..019bd24 100644 (file)
@@ -46,22 +46,16 @@ class Horde_Kolab_Format_EventTest extends PHPUnit_Framework_TestCase
     public function testIssue3525()
     {
         $xml = Horde_Kolab_Format::factory('XML', 'event');
-        if (is_a($xml, 'PEAR_Error')) {
-            $this->assertEquals('', $xml->getMessage());
-        }
 
         // Load XML
         $event = file_get_contents(dirname(__FILE__) . '/fixtures/event_umlaut.xml');
         $result = $xml->load($event);
         // Check that the xml loads fine
-        $this->assertFalse(is_a($result, 'PEAR_Error'));
         $this->assertEquals(mb_convert_encoding($result['body'], 'UTF-8', 'ISO-8859-1'), '...übbe...');
 
         // Load XML
         $event = file_get_contents(dirname(__FILE__) . '/fixtures/event_umlaut_broken.xml');
         $result = $xml->load($event);
-        // Check that the xml loads fine
-        $this->assertFalse(is_a($result, 'PEAR_Error'));
         //FIXME: Why does Kolab Format return ISO-8859-1? UTF-8 would seem more appropriate
         $this->assertEquals(mb_convert_encoding($result['body'], 'UTF-8', 'ISO-8859-1'), '...übbe...');
     }
index c3c6b94..7884cb4 100644 (file)
@@ -75,9 +75,6 @@ class Horde_Kolab_Format_PreferencesTest extends PHPUnit_Framework_TestCase
 
         $xml = file_get_contents(dirname(__FILE__) . '/fixtures/preferences_read_old.xml');
         $object = $preferences->load($xml);
-        if (is_a($object, 'PEAR_Error')) {
-            $this->assertEquals('', $object->getMessage());
-        }
         $this->assertContains('test', $object['pref']);
         $this->assertEquals('Test', $object['application']);
 
@@ -85,9 +82,6 @@ class Horde_Kolab_Format_PreferencesTest extends PHPUnit_Framework_TestCase
                         'pref' => array('test'),
                         'categories' => 'Test');
         $xml = $preferences->save($object);
-        if (is_a($xml, 'PEAR_Error')) {
-            $this->assertEquals('', $xml->getMessage());
-        }
         $expect = file_get_contents(dirname(__FILE__) . '/fixtures/preferences_write_old.xml');
         $this->assertEquals($expect, $xml);
 
@@ -95,9 +89,6 @@ class Horde_Kolab_Format_PreferencesTest extends PHPUnit_Framework_TestCase
                         'pref' => array('test'),
                         'application' => 'Test');
         $xml = $preferences->save($object);
-        if (is_a($xml, 'PEAR_Error')) {
-            $this->assertEquals('', $xml->getMessage());
-        }
         $expect = file_get_contents(dirname(__FILE__) . '/fixtures/preferences_write_old.xml');
         $this->assertEquals($expect, $xml);
     }
index c2db3d8..54b49cc 100644 (file)
@@ -54,23 +54,17 @@ class Horde_Kolab_Format_RecurrenceTest extends PHPUnit_Framework_TestCase
     public function testBug6388()
     {
         $xml = Horde_Kolab_Format::factory('XML', 'event');
-        if (is_a($xml, 'PEAR_Error')) {
-            $this->assertEquals('', $xml->getMessage());
-        }
 
         // Load XML
         $recur = file_get_contents(dirname(__FILE__) . '/fixtures/recur.xml');
 
-        // Check that the xml loads fine
-        $this->assertFalse(is_a($xml->load($recur), 'PEAR_Error'));
-
         // Load XML
         $xml = &Horde_Kolab_Format::factory('XML', 'event');
         $recur = file_get_contents(dirname(__FILE__) . '/fixtures/recur_fail.xml');
 
         // Check that the xml fails because of a missing interval value
         try {
-            $this->assertTrue(is_a($xml->load($recur), 'PEAR_Error'));
+            $xml->load($recur);
             $this->assertTrue(false);
         } catch (Exception $e) {
             $this->assertTrue(is_a($e, 'Horde_Exception'));
@@ -84,17 +78,11 @@ class Horde_Kolab_Format_RecurrenceTest extends PHPUnit_Framework_TestCase
     public function testExceptions()
     {
         $xml = Horde_Kolab_Format::factory('XML', 'event');
-        if (is_a($xml, 'PEAR_Error')) {
-            $this->assertEquals('', $xml->getMessage());
-        }
 
         // Load XML
         $recur = file_get_contents(dirname(__FILE__) . '/fixtures/recur.xml');
 
         $object = $xml->load($recur);
-        if (is_a($object, 'PEAR_Error')) {
-            $this->ensureEquals('', $object->getMessage());
-        }
 
         $r = &new Horde_Date_Recurrence($object['start-date']);
         $r->fromHash($object['recurrence']);
@@ -107,9 +95,6 @@ class Horde_Kolab_Format_RecurrenceTest extends PHPUnit_Framework_TestCase
         $recur = $xml->save($object);
 
         $object = $xml->load($recur);
-        if (is_a($object, 'PEAR_Error')) {
-            $this->ensureEquals('', $object->getMessage());
-        }
 
         $s = &new Horde_Date_Recurrence($object['start-date']);
         $s->fromHash($object['recurrence']);
@@ -125,9 +110,6 @@ class Horde_Kolab_Format_RecurrenceTest extends PHPUnit_Framework_TestCase
     public function testCompletions()
     {
         $xml = Horde_Kolab_Format::factory('XML', 'event');
-        if (is_a($xml, 'PEAR_Error')) {
-            $this->assertEquals('', $xml->getMessage());
-        }
 
         $r = &new Horde_Date_Recurrence(0);
         $r->setRecurType(Horde_Date_Recurrence::RECUR_DAILY);
@@ -141,9 +123,6 @@ class Horde_Kolab_Format_RecurrenceTest extends PHPUnit_Framework_TestCase
         $object['recurrence'] = $r->toHash();
         $recur = $xml->save($object);
         $object = $xml->load($recur);
-        if (is_a($object, 'PEAR_Error')) {
-            $this->ensureEquals('', $object->getMessage());
-        }
 
         $s = &new Horde_Date_Recurrence(0);
         $s->fromHash($object['recurrence']);