* @link http://pear.horde.org/index.php?package=Components
*/
class Components_Exception
-extends Exception
+extends Horde_Exception
{
}
--- /dev/null
+<?php
+/**
+ * This class converts PEAR errors into exceptions for the Components package.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package Components
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Components
+ */
+
+/**
+ * This class converts PEAR errors into exceptions for the Components package.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Horde
+ * @package Components
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Components
+ */
+class Components_Exception_Pear
+extends Horde_Exception_Pear
+{
+ /**
+ * Exception handling.
+ *
+ * @param mixed $result The result to be checked for a PEAR_Error.
+ *
+ * @return mixed Returns the original result if it was no PEAR_Error.
+ *
+ * @throws Horde_Exception_Pear In case the result was a PEAR_Error.
+ */
+ static public function catchError($result)
+ {
+ self::$_class = __CLASS__;
+ return parent::catchError($result);
+ }
+}
)
{
$pkg = new PEAR_PackageFile($environment->getPearConfig());
- $package_file = $pkg->fromPackageFile($package_xml_path, PEAR_VALIDATE_NORMAL);
- if ($package_file instanceOf PEAR_Error) {
- throw new Components_Exception($package_file->getMessage());
- }
- return $package_file;
+ return Components_Exception_Pear::catchError(
+ $pkg->fromPackageFile($package_xml_path, PEAR_VALIDATE_NORMAL)
+ );
}
/**
$pkg->setPearinstallerDep('1.9.0');
$pkg->setPackageType('php');
new PEAR_Validate();
- $package_file = $pkg->getDefaultGenerator()
- ->toPackageFile($package_xml_dir, 0);
- if ($package_file instanceOf PEAR_Error) {
- throw new Components_Exception($package_file->getMessage());
- };
- return $package_file;
+ return Components_Exception_Pear::catchError(
+ $pkg->getDefaultGenerator()
+ ->toPackageFile($package_xml_dir, 0)
+ );
}
/**
);
}
- $package_rw_file = PEAR_PackageFileManager2::importOptions(
- $package_xml_path,
- array(
- 'packagedirectory' => dirname($package_xml_path),
- 'filelistgenerator' => 'file',
- 'clearcontents' => false,
- 'clearchangelog' => false,
- 'simpleoutput' => true,
- 'ignore' => array('*~', 'conf.php', 'CVS/*'),
- 'include' => '*',
- 'dir_roles' =>
+ return Components_Exception_Pear::catchError(
+ PEAR_PackageFileManager2::importOptions(
+ $package_xml_path,
array(
- 'doc' => 'doc',
- 'example' => 'doc',
- 'js' => 'horde',
- 'lib' => 'php',
- 'migration' => 'data',
- 'script' => 'script',
- 'test' => 'test',
- ),
+ 'packagedirectory' => dirname($package_xml_path),
+ 'filelistgenerator' => 'file',
+ 'clearcontents' => false,
+ 'clearchangelog' => false,
+ 'simpleoutput' => true,
+ 'ignore' => array('*~', 'conf.php', 'CVS/*'),
+ 'include' => '*',
+ 'dir_roles' =>
+ array(
+ 'bin' => 'script',
+ 'script' => 'script',
+ 'doc' => 'doc',
+ 'example' => 'doc',
+ 'js' => 'horde',
+ 'horde' => 'horde',
+ 'lib' => 'php',
+ 'migration' => 'data',
+ 'scripts' => 'data',
+ 'test' => 'test',
+ ),
+ )
)
);
-
- if ($package_rw_file instanceOf PEAR_Error) {
- throw new Components_Exception($package_rw_file->getMessage());
- }
- return $package_rw_file;
}
}
\ No newline at end of file
if (!file_exists($this->_config_file)) {
$this->createPearConfig();
}
- $config = PEAR_Config::singleton($this->_config_file);
- if ($config instanceOf PEAR_Error) {
- throw new Components_Exception($config->getMessage());
- }
- return $config;
+ return Components_Exception_Pear::catchError(
+ PEAR_Config::singleton($this->_config_file)
+ );
}
/**
. $channel . '.channel.xml';
if (file_exists($static)) {
ob_start();
- $channel_handler->doAdd('channel-add', array(), array($static));
+ Components_Exception_Pear::catchError(
+ $channel_handler->doAdd('channel-add', array(), array($static))
+ );
$this->_output->pear(ob_get_clean());
} else {
$this->_output->warn(
)
);
ob_start();
- $channel_handler->doDiscover('channel-discover', array(), array($channel));
+ Components_Exception_Pear::catchError(
+ $channel_handler->doDiscover('channel-discover', array(), array($channel))
+ );
$this->_output->pear(ob_get_clean());
}
$this->_output->ok(
}
}
- /**
- * @todo: Looks like this throws away any <replace /> tags we have in
- * the content list. Needs to be fixed.
- */
$package->generateContents();
$updated = $package->getContents();
);
break;
case 'js':
+ case 'horde':
$horde_role = true;
case 'locale':
$package->addInstallAs(
$pkg->setDate(date('Y-m-d'));
$pkg->setTime(date('H:i:s'));
ob_start();
- $result = $pkg->getDefaultGenerator()
- ->toTgz(new PEAR_Common());
+ $result = Components_Exception_Pear::catchError(
+ $pkg->getDefaultGenerator()
+ ->toTgz(new PEAR_Common())
+ );
$this->_output->pear(ob_get_clean());
- if ($result instanceOf PEAR_Error) {
- throw new Components_Exception($result->getMessage());
- }
$this->_output->ok('Generated snapshot ' . $result);
return $result;
}
<email>jan@horde.org</email>
<active>yes</active>
</lead>
- <date>2010-10-23</date>
- <time>00:04:23</time>
+ <date>2010-10-26</date>
+ <time>10:08:57</time>
<version>
<release>0.0.1</release>
<api>0.0.1</api>
<dir name="Dependencies">
<file name="Injector.php" role="php" />
</dir> <!-- /lib/Components/Dependencies -->
+ <dir name="Exception">
+ <file name="Pear.php" role="php" />
+ </dir> <!-- /lib/Components/Exception -->
<dir name="Helper">
<dir name="Tree">
<file name="Element.php" role="php" />
<install as="Components/Config/Application.php" name="lib/Components/Config/Application.php" />
<install as="Components/Config/Cli.php" name="lib/Components/Config/Cli.php" />
<install as="Components/Dependencies/Injector.php" name="lib/Components/Dependencies/Injector.php" />
+ <install as="Components/Exception/Pear.php" name="lib/Components/Exception/Pear.php" />
<install as="Components/Helper/InstallationRun.php" name="lib/Components/Helper/InstallationRun.php" />
<install as="Components/Helper/ListRun.php" name="lib/Components/Helper/ListRun.php" />
<install as="Components/Helper/Tree.php" name="lib/Components/Helper/Tree.php" />
<release>alpha</release>
<api>alpha</api>
</stability>
- <date>2010-10-23</date>
+ <date>2010-10-26</date>
<license uri="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">LGPL</license>
<notes>
* Initial release