level = $level; $this->code = $code; $this->message = $msg; if ($info != null) { $this->info = $info; } if ($backtrace && function_exists( 'debug_backtrace' )) { $this->backtrace = debug_backtrace(); for( $i = count( $this->backtrace ) - 1; $i >= 0; --$i ) { ++$i; if (isset( $this->backtrace[$i]['file'] )) { $this->file = $this->backtrace[$i]['file']; } if (isset( $this->backtrace[$i]['line'] )) { $this->line = $this->backtrace[$i]['line']; } if (isset( $this->backtrace[$i]['class'] )) { $this->class = $this->backtrace[$i]['class']; } if (isset( $this->backtrace[$i]['function'] )) { $this->function = $this->backtrace[$i]['function']; } if (isset( $this->backtrace[$i]['type'] )) { $this->type = $this->backtrace[$i]['type']; } $this->args = false; if (isset( $this->backtrace[$i]['args'] )) { $this->args = $this->backtrace[$i]['args']; } break; } } } /** * Method to get the exception message * * @final * @access public * @return string * @since 1.5 */ function getMessage() { return $this->message; } /** * Method to get the exception code * * @final * @access public * @return integer * @since 1.5 */ function getCode() { return $this->code; } /** * Method to get the source filename where the exception occured * * @final * @access public * @return string * @since 1.5 */ function getFile() { return $this->file; } /** * Method to get the source line where the exception occured * * @final * @access public * @return integer * @since 1.5 */ function getLine() { return $this->line; } /** * Method to get the array of the backtrace() * * @final * @access public * @return array backtrace * @since 1.5 */ function getTrace() { if (isset( $this ) && isset( $this->backtrace )) { $trace = &$this->backtrace; } else { $trace = function_exists( 'debug_backtrace' ) ? debug_backtrace() : null; } return $trace; } /** * Method to get the formatted backtrace information * * @final * @access public * @return string Formated string of trace * @since 1.5 */ function getTraceAsString( ) { //Get the trace array $trace = JException::getTrace(); $result = ''; foreach ($trace as $back) { if (isset($back['file']) && strpos($back['file'], 'error.php') === false) { $result .= '
'.$back['file'].':'.$back['line']; } } return $result; } /** * Returns to error message * * @access public * @return string Error message * @since 1.5 */ function toString() { return $this->message; } }