| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: exception.php 14401 2010-01-26 14:10:00Z louis $ 4 * @package Joomla.Framework 5 * @subpackage Error 6 * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. 7 * @license GNU/GPL, see LICENSE.php 8 * Joomla! is free software. This version may have been modified pursuant 9 * to the GNU General Public License, and as distributed it includes or 10 * is derivative of works licensed under the GNU General Public License or 11 * other free or open source software licenses. 12 * See COPYRIGHT.php for copyright notices and details. 13 */ 14 15 // Check to ensure this file is within the rest of the framework 16 defined('JPATH_BASE') or die(); 17 18 /** 19 * Joomla! Exception object. 20 * 21 * @package Joomla.Framework 22 * @subpackage Error 23 * @since 1.5 24 */ 25 class JException extends JObject 26 { 27 /** 28 * Error level 29 * @var string 30 */ 31 var $level = null; 32 33 /** 34 * Error code 35 * @var string 36 */ 37 var $code = null; 38 39 /** 40 * Error message 41 * @var string 42 */ 43 var $message = null; 44 45 /** 46 * Additional info about the error relevant to the developer 47 * - e.g. if a database connect fails, the dsn used 48 * @var string 49 */ 50 var $info = ''; 51 52 /** 53 * Name of the file the error occurred in [Available if backtrace is enabled] 54 * @var string 55 */ 56 var $file = null; 57 58 /** 59 * Line number the error occurred in [Available if backtrace is enabled] 60 * @var int 61 */ 62 var $line = 0; 63 64 /** 65 * Name of the method the error occurred in [Available if backtrace is enabled] 66 * @var string 67 */ 68 var $function = null; 69 70 /** 71 * Name of the class the error occurred in [Available if backtrace is enabled] 72 * @var string 73 */ 74 var $class = null; 75 76 /** 77 * Error type 78 * @var string 79 */ 80 var $type = null; 81 82 /** 83 * Arguments recieved by the method the error occurred in [Available if backtrace is enabled] 84 * @var array 85 */ 86 var $args = array(); 87 88 /** 89 * Backtrace information 90 * @var mixed 91 */ 92 var $backtrace = null; 93 94 /** 95 * Constructor 96 * - used to set up the error with all needed error details. 97 * 98 * @access protected 99 * @param string $msg The error message 100 * @param string $code The error code from the application 101 * @param int $level The error level (use the PHP constants E_ALL, E_NOTICE etc.). 102 * @param string $info Optional: The additional error information. 103 * @param boolean $backtrace True if backtrace information is to be collected 104 */ 105 function __construct( $msg, $code = 0, $level = null, $info = null, $backtrace = false ) 106 { 107 $this->level = $level; 108 $this->code = $code; 109 $this->message = $msg; 110 111 if ($info != null) { 112 $this->info = $info; 113 } 114 115 if ($backtrace && function_exists( 'debug_backtrace' )) 116 { 117 $this->backtrace = debug_backtrace(); 118 119 for( $i = count( $this->backtrace ) - 1; $i >= 0; --$i ) 120 { 121 ++$i; 122 if (isset( $this->backtrace[$i]['file'] )) { 123 $this->file = $this->backtrace[$i]['file']; 124 } 125 if (isset( $this->backtrace[$i]['line'] )) { 126 $this->line = $this->backtrace[$i]['line']; 127 } 128 if (isset( $this->backtrace[$i]['class'] )) { 129 $this->class = $this->backtrace[$i]['class']; 130 } 131 if (isset( $this->backtrace[$i]['function'] )) { 132 $this->function = $this->backtrace[$i]['function']; 133 } 134 if (isset( $this->backtrace[$i]['type'] )) { 135 $this->type = $this->backtrace[$i]['type']; 136 } 137 138 $this->args = false; 139 if (isset( $this->backtrace[$i]['args'] )) { 140 $this->args = $this->backtrace[$i]['args']; 141 } 142 break; 143 } 144 } 145 } 146 147 /** 148 * Method to get the exception message 149 * 150 * @final 151 * @access public 152 * @return string 153 * @since 1.5 154 */ 155 function getMessage() 156 { 157 return $this->message; 158 } 159 160 /** 161 * Method to get the exception code 162 * 163 * @final 164 * @access public 165 * @return integer 166 * @since 1.5 167 */ 168 function getCode() 169 { 170 return $this->code; 171 } 172 173 /** 174 * Method to get the source filename where the exception occured 175 * 176 * @final 177 * @access public 178 * @return string 179 * @since 1.5 180 */ 181 function getFile() 182 { 183 return $this->file; 184 } 185 186 /** 187 * Method to get the source line where the exception occured 188 * 189 * @final 190 * @access public 191 * @return integer 192 * @since 1.5 193 */ 194 function getLine() 195 { 196 return $this->line; 197 } 198 199 /** 200 * Method to get the array of the backtrace() 201 * 202 * @final 203 * @access public 204 * @return array backtrace 205 * @since 1.5 206 */ 207 function getTrace() 208 { 209 if (isset( $this ) && isset( $this->backtrace )) { 210 $trace = &$this->backtrace; 211 } else { 212 $trace = function_exists( 'debug_backtrace' ) ? debug_backtrace() : null; 213 } 214 215 return $trace; 216 } 217 218 /** 219 * Method to get the formatted backtrace information 220 * 221 * @final 222 * @access public 223 * @return string Formated string of trace 224 * @since 1.5 225 */ 226 function getTraceAsString( ) 227 { 228 //Get the trace array 229 $trace = JException::getTrace(); 230 231 $result = ''; 232 foreach ($trace as $back) 233 { 234 if (isset($back['file']) && strpos($back['file'], 'error.php') === false) { 235 $result .= '<br />'.$back['file'].':'.$back['line']; 236 } 237 } 238 return $result; 239 } 240 241 /** 242 * Returns to error message 243 * 244 * @access public 245 * @return string Error message 246 * @since 1.5 247 */ 248 function toString() 249 { 250 return $this->message; 251 } 252 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |