/** * @covers JError::addToStack */ public function testAddToStack() { // Remove the following lines when the framework is fixed. //$this->markTestSkipped('The framework is currently broken. Skipping this test.'); JErrorInspector::manipulateStack(array('value1', 'value2', 'value3')); $exception = new JException('This is the error message', 1056, 'error'); JError::addToStack($exception); $stack = JErrorInspector::inspectStack(); $this->assertThat($stack[3], $this->identicalTo($exception), 'The exception did not get properly added to the stack'); JErrorInspector::manipulateStack(array()); }
/** * Constructor * - used to set up the error with all needed error details. * * @param string $msg The error message * @param string $code The error code from the application * @param integer $level The error level (use the PHP constants E_ALL, E_NOTICE etc.). * @param string $info Optional: The additional error information. * @param boolean $backtrace True if backtrace information is to be collected * * @since 11.1 * * @deprecated 12.1 */ public function __construct($msg, $code = 0, $level = null, $info = null, $backtrace = false) { JLog::add('JException is deprecated.', JLog::WARNING, 'deprecated'); $this->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; } } // Store exception for debugging purposes! JError::addToStack($this); parent::__construct($msg, (int) $code); }
protected function cleanBogusError() { $errors = array(); while (($error = JError::getError(true)) !== false) { if (!($error->get('code') == 1 && $error->get('level') == 2 && $error->get('message') == JText::_('JLIB_INSTALLER_ERROR_NOTFINDXMLSETUPFILE'))) { $errors[] = $error; } } foreach ($errors as $error) { JError::addToStack($error); } $app =& JFactory::getApplication(); $enqueued_messages = $app->get('_messageQueue'); $other_messages = array(); if (!empty($enqueued_messages) && is_array($enqueued_messages)) { foreach ($enqueued_messages as $enqueued_message) { if (!($enqueued_message['message'] == JText::_('JLIB_INSTALLER_ERROR_NOTFINDXMLSETUPFILE') && $enqueued_message['type']) == 'error') { $other_messages[] = $enqueued_message; } } } $app->set('_messageQueue', $other_messages); }