Skip to content

Commit

Permalink
Make use of exceptions; not PEAR Error
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.php.net/repository/pear/packages/XML_Util2/trunk@313962 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
CloCkWeRX committed Jul 30, 2011
1 parent 4e0da7f commit 4e714ce
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 7 deletions.
10 changes: 4 additions & 6 deletions XML/Util2.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
* @link http://pear.php.net/package/XML_Util2
*/

require_once 'XML/Util2/Exception.php';

/**
* error code for invalid chars in XML name
*/
Expand Down Expand Up @@ -906,10 +908,7 @@ function isValidName($string)
}

/**
* replacement for $this->raiseError
*
* Avoids the necessity to always require
* PEAR.php
*
*
* @param string $msg error message
* @param int $code error code
Expand All @@ -920,8 +919,7 @@ function isValidName($string)
*/
public function raiseError($msg, $code)
{
require_once 'PEAR.php';
return PEAR::raiseError($msg, $code);
throw new XML_Util2_Exception($msg, $code);
}
}
?>
62 changes: 62 additions & 0 deletions XML/Util2/Exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
* XML_Util2
*
* XML Utilities package
*
* PHP version 5
*
* LICENSE:
*
* Copyright (c) 2003-2008 Stephan Schmidt <schst@php.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @category XML
* @package XML_Util2
* @author Daniel O'Connor <clockwerx@php.net>
* @copyright 2011 Daniel O'Connor
* @license http://opensource.org/licenses/bsd-license New BSD License
* @version CVS: $Id: Util2.php 313960 2011-07-30 10:53:11Z clockwerx $
* @link http://pear.php.net/package/XML_Util2
*/

/**
* Exception class for XML_Util2 specific errors
*
* @category XML
* @package XML_Util2
* @author Daniel O'Connor <clockwerx@php.net>
* @copyright 2011 Daniel O'Connor
* @license http://opensource.org/licenses/bsd-license New BSD License
* @version Release: @version@
* @link http://pear.php.net/package/XML_Util2
*/
class XML_Util2_Exception extends Exception {
}
2 changes: 1 addition & 1 deletion package.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
$package->setPearinstallerDep('1.9.3');
$package->addExtensionDep('required', 'pcre');
$package->addIgnore(array('package.php', 'package.xml'));
$package->addReplacement('Util2.php', 'package-info', '@version@', 'version');
$package->addReplacement('XML/Util2.php', 'package-info', '@version@', 'version');
$package->generateContents();

if ($_SERVER['argv'][1] == 'make') {
Expand Down

0 comments on commit 4e714ce

Please sign in to comment.