[ Index ] |
|
Code source de Joomla 1.0.13 |
1 <?php 2 /** 3 * patError error object used by the patFormsError manager as error messages 4 * container for precise error management. 5 * 6 * $Id: patError.php 49 2005-09-15 02:55:27Z rhuk $ 7 * 8 * @access public 9 * @package patError 10 */ 11 12 /** 13 * patError error object used by the patFormsError manager as error messages 14 * container for precise error management. 15 * 16 * $Id: patError.php 49 2005-09-15 02:55:27Z rhuk $ 17 * 18 * @access public 19 * @package patError 20 * @version 0.3 21 * @author gERD Schaufelberger <gerd@php-tools.net> 22 * @author Sebastian Mordziol <argh@php-tools.net> 23 * @author Stephan Schmidt <schst@php-tools.net> 24 * @license LGPL 25 * @link http://www.php-tools.net 26 */ 27 class patError 28 { 29 /** 30 * stores the error level for this error 31 * 32 * @access private 33 * @var string 34 */ 35 var $level = null; 36 37 /** 38 * stores the code of the error 39 * 40 * @access private 41 * @var string 42 */ 43 var $code = null; 44 45 /** 46 * stores the error message - this is the message that can also be shown the 47 * user if need be. 48 * 49 * @access private 50 * @var string 51 */ 52 var $message = null; 53 54 /** 55 * additional info that is relevant for the developer of the script (e.g. if 56 * a database connect fails, the dsn used) and that the end-user should not 57 * see. 58 * 59 * @access private 60 * @var string 61 */ 62 var $info = ''; 63 64 /** 65 * stores the filename of the file the error occurred in. 66 * 67 * @access private 68 * @var string 69 */ 70 var $file = ''; 71 72 /** 73 * stores the line number the error occurred in. 74 * 75 * @access private 76 * @var integer 77 */ 78 var $line = 0; 79 80 /** 81 * stores the name of the method the error occurred in 82 * 83 * @access private 84 * @var string 85 */ 86 var $function = ''; 87 88 /** 89 * stores the name of the class (if any) the error occurred in. 90 * 91 * @access private 92 * @var string 93 */ 94 var $class = ''; 95 96 /** 97 * stores the type of error, as it is listed in the error backtrace 98 * 99 * @access private 100 * @var string 101 */ 102 var $type = ''; 103 104 /** 105 * stores the arguments the method that the error occurred in had received. 106 * 107 * @access private 108 * @var array 109 */ 110 var $args = array(); 111 112 /** 113 * stores the complete debug backtrace (if your PHP version has the 114 * debug_backtrace function) 115 * 116 * @access private 117 * @var mixed 118 */ 119 var $backtrace = false; 120 121 /** 122 * constructor, wrapper for the upcoming PHP5 constructors for upward 123 * compatibility. 124 * 125 * @access public 126 * @param int $level The error level (use the PHP constants E_ALL, E_NOTICE etc.). 127 * @param string $code The error code from the application 128 * @param string $msg The error message 129 * @param string $info Optional: The additional error information. 130 * @see __construct() 131 */ 132 function patError( $level, $code, $msg, $info = null ) 133 { 134 $this->__construct( $level, $code, $msg, $info ); 135 } 136 137 /** 138 * constructor - used to set up the error with all needed error details. 139 * 140 * @access public 141 * @param int $level The error level (use the PHP constants E_ALL, E_NOTICE etc.). 142 * @param string $code The error code from the application 143 * @param string $msg The error message 144 * @param string $info Optional: The additional error information. 145 * @todo all calls to patErrorManager::raise* should not be included in backtrace 146 */ 147 function __construct( $level, $code, $msg, $info = null ) 148 { 149 static $raise = array( 'raise', 150 'raiseerror', 151 'raisewarning', 152 'raisenotice' 153 ); 154 155 $this->level = $level; 156 $this->code = $code; 157 $this->message = $msg; 158 159 if( $info != null ) 160 { 161 $this->info = $info; 162 } 163 164 if( function_exists( 'debug_backtrace' ) ) 165 { 166 $this->backtrace = debug_backtrace(); 167 168 for( $i = count( $this->backtrace ) - 1; $i >= 0; --$i ) 169 { 170 if( in_array( $this->backtrace[$i]['function'], $raise ) ) 171 { 172 ++$i; 173 if( isset( $this->backtrace[$i]['file'] ) ) 174 $this->file = $this->backtrace[$i]['file']; 175 if( isset( $this->backtrace[$i]['line'] ) ) 176 $this->line = $this->backtrace[$i]['line']; 177 if( isset( $this->backtrace[$i]['class'] ) ) 178 $this->class = $this->backtrace[$i]['class']; 179 if( isset( $this->backtrace[$i]['function'] ) ) 180 $this->function = $this->backtrace[$i]['function']; 181 if( isset( $this->backtrace[$i]['type'] ) ) 182 $this->type = $this->backtrace[$i]['type']; 183 184 $this->args = false; 185 if( isset( $this->backtrace[$i]['args'] ) ) 186 { 187 $this->args = $this->backtrace[$i]['args']; 188 } 189 break; 190 } 191 } 192 } 193 } 194 195 /** 196 * returns the error level of the error - corresponds to the PHP 197 * error levels (E_ALL, E_NOTICE...) 198 * 199 * @access public 200 * @return int $level The error level 201 * @see $level 202 */ 203 function getLevel() 204 { 205 return $this->level; 206 } 207 208 209 /** 210 * retrieves the error message 211 * 212 * @access public 213 * @return string $msg The stored error message 214 * @see $message 215 */ 216 function getMessage() 217 { 218 return $this->message; 219 } 220 221 /** 222 * retrieves the additional error information (information usually 223 * only relevant for developers) 224 * 225 * @access public 226 * @return mixed $info The additional information 227 * @see $info 228 */ 229 function getInfo() 230 { 231 return $this->info; 232 } 233 234 /** 235 * recieve error code 236 * 237 * @access public 238 * @return string|integer error code (may be a string or an integer) 239 * @see $code 240 */ 241 function getCode() 242 { 243 return $this->code; 244 } 245 246 /** 247 * get the backtrace 248 * 249 * This is only possible, if debug_backtrace() is available. 250 * 251 * @access public 252 * @return array backtrace 253 * @see $backtrace 254 */ 255 function getBacktrace( $formatted=false ) 256 { 257 if ($formatted && is_array( $this->backtrace )) { 258 $result = ''; 259 foreach( debug_backtrace() as $back) { 260 if (!eregi( 'patErrorManager.php', $back['file'])) { 261 $result .= '<br />'.$back['file'].':'.$back['line']; 262 } 263 } 264 return $result; 265 } 266 return $this->backtrace; 267 } 268 269 /** 270 * get the filename in which the error occured 271 * 272 * This is only possible, if debug_backtrace() is available. 273 * 274 * @access public 275 * @return string filename 276 * @see $file 277 */ 278 function getFile() 279 { 280 return $this->file; 281 } 282 283 /** 284 * get the line number in which the error occured 285 * 286 * This is only possible, if debug_backtrace() is available. 287 * 288 * @access public 289 * @return integer line number 290 * @see $line 291 */ 292 function getLine() 293 { 294 return $this->line; 295 } 296 } 297 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 14:43:32 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |