Source for file RSError.php

Documentation is available at RSError.php


1 <?php
2 // RSErrorManager: A Pear Error Manager
3 // Copyright (C) 2003 Lukas Feiler
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 /**Contains the class RSError
20 *
21 * @author Lukas Feiler <lukas.feiler@chello.at>
22 * @version 0.1.9
23 * @copyright Lukas Feiler 2003
24 * @package RSErrorManager
25 * @filesource
26 */
27
28 /**RSError extends PEAR_Error.
29 */
30 require_once('PEAR.php');
31
32 /**An extended version of PEAR_Error.
33 *
34 * RSError is capable of handling the parameter $userinfo as an associative array
35 * with additional information about the error: object, property and operation.
36 * It is recommende to use the wrapper RSErrorManager::raiseRSError to raise a new RSError.
37 * @see RSErrorManager::raiseRSError
38 *
39 * @author Lukas Feiler <lukas.feiler@chello.at>
40 * @version 0.1.9
41 * @copyright Lukas Feiler 2003
42 * @package RSErrorManager
43 */
44 class RSError extends PEAR_Error {
45
46 /**The name of the object to which the error is related.
47 * @var String
48 */
49 var $object = null;
50
51 /**The name of the property to which the error is related.
52 * @var String
53 */
54 var $property = null;
55
56 /**The name of the operation to which the error is related.
57 * @var String
58 */
59 var $operation = null;
60
61 /**Constructor method.
62 *
63 * The constructor calls the parent constructor PEAR_Error with the arguments $message, $code, $mode,
64 * $options and $userinfo.
65 * Before doing so the private fields object, property and operation are set if the parameter $userinfo
66 * is an associativ array. The associative array should contain tree key-value-pairs:
67 * The key 'object' pointing to the name of the object to which the error is related.
68 * The key 'property' pointing to the name of the property to which the error is related.
69 * The key 'operation' pointing to the name of the operation to which the error is related.
70 *
71 * @param mixed $message A text error message or a PEAR error object.
72 * @param int $code A numeric error code.
73 * @param int $mode One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, PEAR_ERROR_TRIGGER,
74 * PEAR_ERROR_DIE or PEAR_ERROR_CALLBACK.
75 * @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter
76 * specifies the PHP-internal error level (one of E_USER_NOTICE, E_USER_WARNING or
77 * E_USER_ERROR). If $mode is PEAR_ERROR_CALLBACK, this parameter specifies the
78 * callback function or method. In other error modes this parameter is ignored.
79 * @param mixed $userinfo A string or an associative array defining the elements
80 * 'object', 'property' and 'operation'.
81 */
82 function RSError($message = 'unknown error', $code = null, $mode = null, $options = null, $userinfo = null)
83 {
84 if (is_array($userinfo)) {
85 $this->object = $userinfo['object'];
86 $this->property = $userinfo['property'];
87 $this->operation = $userinfo['operation'];
88 }
89 $this->PEAR_Error($message, $code, $mode, $options, $userinfo);
90 }
91
92 /**Returns the value of the field object.
93 * @see object
94 *
95 * @return String.
96 */
97 function getObject()
98 {
99 return $this->object;
100 }
101
102 /**Returns the value of the field property.
103 * @see property
104 *
105 * @return String.
106 */
107 function getProperty()
108 {
109 return $this->property;
110 }
111
112 /**Returns the value of the field operation.
113 * @see operation
114 *
115 * @return String.
116 */
117 function getOperation()
118 {
119 return $this->operation;
120 }
121
122 /**Returns a literal representation of this error.
123 *
124 * Overwrites the method toString inherited by PEAR_Error.
125 * Note that the return value of PEAR_Error::toString is appended.
126 * @see PEAR_Error::toString
127 *
128 * @return String
129 */
130 function toString()
131 {
132 return "$this->object : $this->property : $this->operation - " . PEAR_Error::toString();
133 }
134 }
135 ?>

Documentation generated on Mon, 8 Dec 2003 13:13:04 +0100 by phpDocumentor 1.2.3