uw              Thu Mar  8 12:39:17 2001 EDT

  Added files:                 
    /php4/pear/Cache    Error.php 

  Modified files:              
    /php4/pear  Cache.php 
    /php4/pear/Cache    Container.php 
    /php4/pear/Cache/Container  db.php file.php phplib.php 
  Log:
  Added a basic Cache_Error class.
  
  
  
Index: php4/pear/Cache.php
diff -u php4/pear/Cache.php:1.5 php4/pear/Cache.php:1.6
--- php4/pear/Cache.php:1.5     Tue Mar  6 07:27:30 2001
+++ php4/pear/Cache.php Thu Mar  8 12:39:15 2001
@@ -16,15 +16,17 @@
 // |          Sebastian Bergmann <[EMAIL PROTECTED]>               |
 // +----------------------------------------------------------------------+
 //
-// $Id: Cache.php,v 1.5 2001/03/06 15:27:30 sbergmann Exp $
+// $Id: Cache.php,v 1.6 2001/03/08 20:39:15 uw Exp $
 
+require_once "Cache/Error.php";
+
 /**
 * Cache is a base class for cache implementations.
 *
 * TODO: Simple usage example goes here.
 *
 * @author   Ulf Wendel <[EMAIL PROTECTED]>
-* @version  $Id: Cache.php,v 1.5 2001/03/06 15:27:30 sbergmann Exp $
+* @version  $Id: Cache.php,v 1.6 2001/03/08 20:39:15 uw Exp $
 * @package  Cache
 * @access   public 
 */
@@ -136,7 +138,7 @@
     * @param    mixed   userdefined expire date
     * @param    string  cache group
     * @return   boolean
-    * @throws   CacheError
+    * @throws   Cache_Error
     * @access   public
     * @see      getUserdata()
     */
Index: php4/pear/Cache/Container.php
diff -u php4/pear/Cache/Container.php:1.7 php4/pear/Cache/Container.php:1.8
--- php4/pear/Cache/Container.php:1.7   Thu Mar  8 03:57:15 2001
+++ php4/pear/Cache/Container.php       Thu Mar  8 12:39:15 2001
@@ -17,8 +17,10 @@
 // |          Christian Stocker <[EMAIL PROTECTED]>                         |
 // +----------------------------------------------------------------------+
 //
-// $Id: Container.php,v 1.7 2001/03/08 11:57:15 chregu Exp $
+// $Id: Container.php,v 1.8 2001/03/08 20:39:15 uw Exp $
 
+require_once "Cache/Error.php";
+
 /**
 * Common base class of all cache storage container.
 * 
@@ -37,7 +39,7 @@
 * not recommended!
 * 
 * @author   Ulf Wendel <[EMAIL PROTECTED]>
-* @version  $Id: Container.php,v 1.7 2001/03/08 11:57:15 chregu Exp $
+* @version  $Id: Container.php,v 1.8 2001/03/08 20:39:15 uw Exp $
 * @package  Cache
 * @access   public
 * @abstract
@@ -208,7 +210,7 @@
     * @param    string  dataset ID
     * @param    string  cache group
     * @return   array   format: [expire date, cached data, user data]
-    * @throws   CacheError
+    * @throws   Cache_Error
     * @abstract
     */
     function fetch($id, $group) {
@@ -224,7 +226,7 @@
     * @param    string  cache group
     * @param    string  additional userdefined data
     * @return   boolean
-    * @throws   CacheError
+    * @throws   Cache_Error
     * @access   public
     * @abstract
     */
Index: php4/pear/Cache/Container/db.php
diff -u php4/pear/Cache/Container/db.php:1.8 php4/pear/Cache/Container/db.php:1.9
--- php4/pear/Cache/Container/db.php:1.8        Thu Mar  8 03:57:16 2001
+++ php4/pear/Cache/Container/db.php    Thu Mar  8 12:39:16 2001
@@ -17,7 +17,7 @@
 // |          Chuck Hagenbuch <[EMAIL PROTECTED]>                           |
 // +----------------------------------------------------------------------+
 //
-// $Id: db.php,v 1.8 2001/03/08 11:57:16 chregu Exp $
+// $Id: db.php,v 1.9 2001/03/08 20:39:16 uw Exp $
 
 require_once 'DB.php';
 require_once 'Cache/Container.php';
@@ -52,7 +52,7 @@
 * )
 *
 * @author   Sebastian Bergmann <[EMAIL PROTECTED]>
-* @version  $Id: db.php,v 1.8 2001/03/08 11:57:16 chregu Exp $
+* @version  $Id: db.php,v 1.9 2001/03/08 20:39:16 uw Exp $
 * @package  Cache
 */
 class Cache_Container_db extends Cache_Container {
@@ -81,17 +81,17 @@
     function Cache_Container_db($options)
     {
         if (!is_array($options) || !isset($options['dsn'])) {
-            return new CacheError('No dsn specified!', __FILE__, __LINE__);
+            return new Cache_Error('No dsn specified!', __FILE__, __LINE__);
         }
 
         $this->setOptions($options, array('dsn', 'cache_table'));
 
         if (!$this->dsn)
-            return new CacheError('No dsn specified!', __FILE__, __LINE__);
+            return new Cache_Error('No dsn specified!', __FILE__, __LINE__);
 
         $this->db = DB::connect($this->dsn, true);
         if (DB::isError($this->db)) {
-            return new CacheError('DB::connect failed: ' . 
DB::errorMessage($this->db), __FILE__, __LINE__);
+            return new Cache_Error('DB::connect failed: ' . 
+DB::errorMessage($this->db), __FILE__, __LINE__);
         } else {
             $this->db->setFetchMode(DB_FETCHMODE_ASSOC);
         }
@@ -108,7 +108,7 @@
         $res = $this->db->query($query);
 
         if (DB::isError($res))
-            return new CacheError('DB::query failed: ' . DB::errorMessage($res), 
__FILE__, __LINE__);
+            return new Cache_Error('DB::query failed: ' . DB::errorMessage($res), 
+__FILE__, __LINE__);
 
         $row = $res->fetchRow();
 
@@ -139,7 +139,7 @@
         $res = $this->db->query($query);
 
         if (DB::isError($res)) {
-            return new CacheError('DB::query failed: ' . DB::errorMessage($res) , 
__FILE__, __LINE__);
+            return new Cache_Error('DB::query failed: ' . DB::errorMessage($res) , 
+__FILE__, __LINE__);
         }
     }
 
@@ -156,7 +156,7 @@
         $res = $this->db->query($query);
 
         if (DB::isError($res))
-            return new CacheError('DB::query failed: ' . DB::errorMessage($res), 
__FILE__, __LINE__);
+            return new Cache_Error('DB::query failed: ' . DB::errorMessage($res), 
+__FILE__, __LINE__);
     }
 
     function flush($group = "")
@@ -172,7 +172,7 @@
         $res = $this->db->query($query);
 
         if (DB::isError($res))
-            return new CacheError('DB::query failed: ' . DB::errorMessage($res), 
__FILE__, __LINE__);
+            return new Cache_Error('DB::query failed: ' . DB::errorMessage($res), 
+__FILE__, __LINE__);
     }
 
     function idExists($id, $group)
@@ -186,7 +186,7 @@
         $res = $this->db->query($query);
 
         if (DB::isError($res))
-            return new CacheError('DB::query failed: ' . DB::errorMessage($res), 
__FILE__, __LINE__);
+            return new Cache_Error('DB::query failed: ' . DB::errorMessage($res), 
+__FILE__, __LINE__);
 
         $row = $res->fetchRow();
 
@@ -206,7 +206,7 @@
         $res = $this->db->query($query);
 
         if (DB::isError($res)) {
-            return new CacheError('DB::query failed: ' . DB::errorMessage($res), 
__FILE__, __LINE__);
+            return new Cache_Error('DB::query failed: ' . DB::errorMessage($res), 
+__FILE__, __LINE__);
         }
     }
 }
Index: php4/pear/Cache/Container/file.php
diff -u php4/pear/Cache/Container/file.php:1.7 php4/pear/Cache/Container/file.php:1.8
--- php4/pear/Cache/Container/file.php:1.7      Thu Mar  8 03:57:16 2001
+++ php4/pear/Cache/Container/file.php  Thu Mar  8 12:39:16 2001
@@ -16,7 +16,7 @@
 // |          Sebastian Bergmann <[EMAIL PROTECTED]>               |
 // +----------------------------------------------------------------------+
 //
-// $Id: file.php,v 1.7 2001/03/08 11:57:16 chregu Exp $
+// $Id: file.php,v 1.8 2001/03/08 20:39:16 uw Exp $
 
 require_once 'Cache/Container.php';
 
@@ -24,7 +24,7 @@
 * Stores cache contents in a file.
 *
 * @author   Ulf Wendel  <[EMAIL PROTECTED]>
-* @version  $Id: file.php,v 1.7 2001/03/08 11:57:16 chregu Exp $
+* @version  $Id: file.php,v 1.8 2001/03/08 20:39:16 uw Exp $
 */
 class Cache_Container_file extends Cache_Container {
 
@@ -76,7 +76,7 @@
 
         // retrive the content
         if (!($fh = @fopen($file, "rb")))
-            return new CacheError("Can't access cache file '$file'. Check access 
rights and path.", __FILE__, __LINE__);
+            return new Cache_Error("Can't access cache file '$file'. Check access 
+rights and path.", __FILE__, __LINE__);
 
         // file format:
         // 1st line: expiration date
@@ -101,7 +101,7 @@
 
         $file = $this->getFilename($id, $group);
         if (!($fh = @fopen($file, "wb")))
-            return new CacheError("Can't access '$file' to store cache data. Check 
access rights and path.", __FILE__, __LINE__);
+            return new Cache_Error("Can't access '$file' to store cache data. Check 
+access rights and path.", __FILE__, __LINE__);
 
         // file format:
         // 1st line: expiration date
@@ -170,7 +170,7 @@
             $dir = $this->cache_dir;
 
         if (!($dh = opendir($dir)))
-            return new CacheError("Can't access cache directory '$dir'. Check 
permissions and path.", __FILE__, __LINE__);
+            return new Cache_Error("Can't access cache directory '$dir'. Check 
+permissions and path.", __FILE__, __LINE__);
 
         while ($file = readdir($dh)) {
             if ("." == $file || ".." == $file)
@@ -182,7 +182,7 @@
 
             // skip trouble makers but inform the user
             if (!($fh = @fopen($file, "rb"))) {
-                new CacheError("Can't access cache file '$file', skipping it. Check 
permissions and path.", __FILE__, __LINE__);
+                new Cache_Error("Can't access cache file '$file', skipping it. Check 
+permissions and path.", __FILE__, __LINE__);
                 continue;
             }
 
@@ -191,7 +191,7 @@
 
             // remove if expired
             if ($expire && $expire <= time() && !unlink($file))
-                new CacheError("Can't unlink cache file '$file', skipping. Check 
permissions and path.", __FILE__, __LINE__);
+                new Cache_Error("Can't unlink cache file '$file', skipping. Check 
+permissions and path.", __FILE__, __LINE__);
         }
 
         closedir($dh);
@@ -230,11 +230,11 @@
     * 
     * @param    string  directory
     * @return   integer number of removed files
-    * @throws   CacheError
+    * @throws   Cache_Error
     */
     function deleteDir($dir) {
         if (!($dh = opendir($dir)))
-            return new CacheError("Can't remove directory '$dir'. Check permissions 
and path.", __FILE__, __LINE__);
+            return new Cache_Error("Can't remove directory '$dir'. Check permissions 
+and path.", __FILE__, __LINE__);
 
         $num_removed = 0;
 
Index: php4/pear/Cache/Container/phplib.php
diff -u php4/pear/Cache/Container/phplib.php:1.9 
php4/pear/Cache/Container/phplib.php:1.10
--- php4/pear/Cache/Container/phplib.php:1.9    Thu Mar  8 03:57:16 2001
+++ php4/pear/Cache/Container/phplib.php        Thu Mar  8 12:39:16 2001
@@ -16,7 +16,7 @@
 // |          Sebastian Bergmann <[EMAIL PROTECTED]>               |
 // +----------------------------------------------------------------------+
 //
-// $Id: phplib.php,v 1.9 2001/03/08 11:57:16 chregu Exp $
+// $Id: phplib.php,v 1.10 2001/03/08 20:39:16 uw Exp $
 
 require_once 'Cache/Container.php';
 
@@ -51,7 +51,7 @@
 *
 * 
 * @author   Ulf Wendel  <[EMAIL PROTECTED]>, Sebastian Bergmann 
<[EMAIL PROTECTED]>
-* @version  $Id: phplib.php,v 1.9 2001/03/08 11:57:16 chregu Exp $
+* @version  $Id: phplib.php,v 1.10 2001/03/08 20:39:16 uw Exp $
 * @package  Cache
 * @see      save()
 */
@@ -122,7 +122,7 @@
             $this->setOptions($options, array("db_class", "db_file", "db_path", 
"local_file", "local_path"));
 
         if (!$this->db_class)
-            return new CacheError("No database class specified.", __FILE__, __LINE__);
+            return new Cache_Error("No database class specified.", __FILE__, 
+__LINE__);
 
         // include the required files
         if ($this->db_file)

Index: php4/pear/Cache/Error.php
+++ php4/pear/Cache/Error.php
<?php
/**
* Cache Error class
* 
* @package Cache
*/
class Cache_Error extends PEAR_Error {


  /**
  * Prefix of all error messages.
  * 
  * @var  string
  */
  var $error_message_prefix = "Cache-Error: ";
  
  /**
  * Creates an cache error object.
  * 
  * @param  string  error message
  * @param  string  file where the error occured
  * @param  string  linenumber where the error occured
  */
  function Cache_Error($msg, $file = __FILE__, $line = __LINE__) {
    
    $this->PEAR_Error(sprintf("%s [%s on line %d].", $msg, $file, $line));
    
  } // end func Cache_Error
  
} // end class Cache_Error
?>
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to