PageRenderTime 5ms CodeModel.GetById 18ms app.highlight 33ms RepoModel.GetById 1ms app.codeStats 0ms

/libraries/legacy/error/error.php

https://bitbucket.org/eternaware/joomus
PHP | 885 lines | 396 code | 104 blank | 385 comment | 40 complexity | 4d20ca2b152af2e125d85407eab66d0b MD5 | raw file
  1<?php
  2/**
  3 * @package     Joomla.Legacy
  4 * @subpackage  Error
  5 *
  6 * @copyright   Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
  7 * @license     GNU General Public License version 2 or later; see LICENSE
  8 */
  9
 10defined('JPATH_PLATFORM') or die;
 11
 12// Error Definition: Illegal Options
 13const JERROR_ILLEGAL_OPTIONS = 1;
 14
 15// Error Definition: Callback does not exist
 16const JERROR_CALLBACK_NOT_CALLABLE = 2;
 17
 18// Error Definition: Illegal Handler
 19const JERROR_ILLEGAL_MODE = 3;
 20
 21/**
 22 * Error Handling Class
 23 *
 24 * This class is inspired in design and concept by patErrorManager <http://www.php-tools.net>
 25 *
 26 * patErrorManager contributors include:
 27 * - gERD Schaufelberger	<gerd@php-tools.net>
 28 * - Sebastian Mordziol	<argh@php-tools.net>
 29 * - Stephan Schmidt		<scst@php-tools.net>
 30 *
 31 * @package     Joomla.Legacy
 32 * @subpackage  Error
 33 * @since       11.1
 34 * @deprecated  12.1   Use PHP Exception
 35 */
 36abstract class JError
 37{
 38	/**
 39	 * Legacy error handling marker
 40	 *
 41	 * @var    boolean  True to enable legacy error handling using JError, false to use exception handling.  This flag
 42	 *                  is present to allow an easy transition into exception handling for code written against the
 43	 *                  existing JError API in Joomla.
 44	 * @since  11.1
 45	 */
 46	public static $legacy = false;
 47
 48	/**
 49	 * Array of message levels
 50	 *
 51	 * @var    array
 52	 * @since  11.1
 53	 */
 54	protected static $levels = array(E_NOTICE => 'Notice', E_WARNING => 'Warning', E_ERROR => 'Error');
 55
 56	protected static $handlers = array(
 57		E_NOTICE => array('mode' => 'ignore'),
 58		E_WARNING => array('mode' => 'ignore'),
 59		E_ERROR => array('mode' => 'ignore')
 60	);
 61
 62	protected static $stack = array();
 63
 64	/**
 65	 * Method to determine if a value is an exception object.
 66	 *
 67	 * @param   mixed  $object  Object to check.
 68	 *
 69	 * @return  boolean  True if argument is an exception, false otherwise.
 70	 *
 71	 * @deprecated  12.1
 72	 * @since   11.1
 73	 */
 74	public static function isError($object)
 75	{
 76		JLog::add('JError::isError() is deprecated.', JLog::WARNING, 'deprecated');
 77
 78		return $object instanceof Exception;
 79	}
 80
 81	/**
 82	 * Method for retrieving the last exception object in the error stack
 83	 *
 84	 * @param   boolean  $unset  True to remove the error from the stack.
 85	 *
 86	 * @return  mixed  Last exception object in the error stack or boolean false if none exist
 87	 *
 88	 * @deprecated  12.1
 89	 * @since   11.1
 90	 */
 91	public static function getError($unset = false)
 92	{
 93		JLog::add('JError::getError() is deprecated.', JLog::WARNING, 'deprecated');
 94
 95		if (!isset(self::$stack[0]))
 96		{
 97			return false;
 98		}
 99
100		if ($unset)
101		{
102			$error = array_shift(self::$stack);
103		}
104		else
105		{
106			$error = &self::$stack[0];
107		}
108		return $error;
109	}
110
111	/**
112	 * Method for retrieving the exception stack
113	 *
114	 * @return  array  Chronological array of errors that have been stored during script execution
115	 *
116	 * @deprecated  12.1
117	 * @since   11.1
118	 */
119	public static function getErrors()
120	{
121		JLog::add('JError::getErrors() is deprecated.', JLog::WARNING, 'deprecated');
122
123		return self::$stack;
124	}
125
126	/**
127	 * Method to add non-JError thrown JExceptions to the JError stack for debugging purposes
128	 *
129	 * @param   JException  &$e  Add an exception to the stack.
130	 *
131	 * @return  void
132	 *
133	 * @since       11.1
134	 * @deprecated  12.1
135	 */
136	public static function addToStack(JException &$e)
137	{
138		JLog::add('JError::addToStack() is deprecated.', JLog::WARNING, 'deprecated');
139
140		self::$stack[] = &$e;
141	}
142
143	/**
144	 * Create a new JException object given the passed arguments
145	 *
146	 * @param   integer  $level      The error level - use any of PHP's own error levels for
147	 *                               this: E_ERROR, E_WARNING, E_NOTICE, E_USER_ERROR,
148	 *                               E_USER_WARNING, E_USER_NOTICE.
149	 * @param   string   $code       The application-internal error code for this error
150	 * @param   string   $msg        The error message, which may also be shown the user if need be.
151	 * @param   mixed    $info       Optional: Additional error information (usually only
152	 *                               developer-relevant information that the user should never see,
153	 *                               like a database DSN).
154	 * @param   boolean  $backtrace  Add a stack backtrace to the exception.
155	 *
156	 * @return  mixed    The JException object
157	 *
158	 * @since       11.1
159	 * @deprecated  12.1  Use PHP Exception
160	 * @see         JException
161	 */
162	public static function raise($level, $code, $msg, $info = null, $backtrace = false)
163	{
164		JLog::add('JError::raise() is deprecated.', JLog::WARNING, 'deprecated');
165
166		// Build error object
167		$exception = new JException($msg, $code, $level, $info, $backtrace);
168		return self::throwError($exception);
169	}
170
171	/**
172	 * Throw an error
173	 *
174	 * @param   object  &$exception  An exception to throw.
175	 *
176	 * @return  reference
177	 *
178	 * @deprecated  12.1  Use PHP Exception
179	 * @see     JException
180	 * @since   11.1
181	 */
182	public static function throwError(&$exception)
183	{
184		JLog::add('JError::throwError() is deprecated.', JLog::WARNING, 'deprecated');
185
186		static $thrown = false;
187
188		// If thrown is hit again, we've come back to JError in the middle of throwing another JError, so die!
189		if ($thrown)
190		{
191			self::handleEcho($exception, array());
192
193			// Inifite loop.
194			jexit();
195		}
196
197		$thrown = true;
198		$level = $exception->get('level');
199
200		// See what to do with this kind of error
201		$handler = self::getErrorHandling($level);
202
203		$function = 'handle' . ucfirst($handler['mode']);
204		if (is_callable(array('JError', $function)))
205		{
206			$reference = call_user_func_array(array('JError', $function), array(&$exception, (isset($handler['options'])) ? $handler['options'] : array()));
207		}
208		else
209		{
210			// This is required to prevent a very unhelpful white-screen-of-death
211			jexit(
212				'JError::raise -> Static method JError::' . $function . ' does not exist.' . ' Contact a developer to debug' .
213				'<br /><strong>Error was</strong> ' . '<br />' . $exception->getMessage()
214			);
215		}
216		// We don't need to store the error, since JException already does that for us!
217		// Remove loop check
218		$thrown = false;
219
220		return $reference;
221	}
222
223	/**
224	 * Wrapper method for the raise() method with predefined error level of E_ERROR and backtrace set to true.
225	 *
226	 * @param   string  $code  The application-internal error code for this error
227	 * @param   string  $msg   The error message, which may also be shown the user if need be.
228	 * @param   mixed   $info  Optional: Additional error information (usually only
229	 *                         developer-relevant information that the user should
230	 *                         never see, like a database DSN).
231	 *
232	 * @return  object  $error  The configured JError object
233	 *
234	 * @deprecated   12.1       Use PHP Exception
235	 * @see        raise()
236	 * @since   11.1
237	 */
238	public static function raiseError($code, $msg, $info = null)
239	{
240		JLog::add('JError::raiseError() is deprecated.', JLog::WARNING, 'deprecated');
241
242		return self::raise(E_ERROR, $code, $msg, $info, true);
243	}
244
245	/**
246	 * Wrapper method for the {@link raise()} method with predefined error level of E_WARNING and
247	 * backtrace set to false.
248	 *
249	 * @param   string  $code  The application-internal error code for this error
250	 * @param   string  $msg   The error message, which may also be shown the user if need be.
251	 * @param   mixed   $info  Optional: Additional error information (usually only
252	 *                         developer-relevant information that
253	 *                         the user should never see, like a database DSN).
254	 *
255	 * @return  object  The configured JError object
256	 *
257	 * @deprecated  12.1  Use PHP Exception
258	 * @see        JError
259	 * @see        raise()
260	 * @since      11.1
261	 */
262	public static function raiseWarning($code, $msg, $info = null)
263	{
264		JLog::add('JError::raiseWarning() is deprecated.', JLog::WARNING, 'deprecated');
265
266		return self::raise(E_WARNING, $code, $msg, $info);
267	}
268
269	/**
270	 * Wrapper method for the {@link raise()} method with predefined error
271	 * level of E_NOTICE and backtrace set to false.
272	 *
273	 * @param   string  $code  The application-internal error code for this error
274	 * @param   string  $msg   The error message, which may also be shown the user if need be.
275	 * @param   mixed   $info  Optional: Additional error information (usually only
276	 *                         developer-relevant information that the user
277	 *                         should never see, like a database DSN).
278	 *
279	 * @return  object   The configured JError object
280	 *
281	 * @deprecated       12.1   Use PHP Exception
282	 * @see     raise()
283	 * @since   11.1
284	 */
285	public static function raiseNotice($code, $msg, $info = null)
286	{
287		JLog::add('JError::raiseNotice() is deprecated.', JLog::WARNING, 'deprecated');
288
289		return self::raise(E_NOTICE, $code, $msg, $info);
290	}
291
292	/**
293	 * Method to get the current error handler settings for a specified error level.
294	 *
295	 * @param   integer  $level  The error level to retrieve. This can be any of PHP's
296	 *                           own error levels, e.g. E_ALL, E_NOTICE...
297	 *
298	 * @return  array    All error handling details
299	 *
300	 * @deprecated   12.1  Use PHP Exception
301	 * @since   11.1
302	 */
303	public static function getErrorHandling($level)
304	{
305		JLog::add('JError::getErrorHandling() is deprecated.', JLog::WARNING, 'deprecated');
306
307		return self::$handlers[$level];
308	}
309
310	/**
311	 * Method to set the way the JError will handle different error levels. Use this if you want to override the default settings.
312	 *
313	 * Error handling modes:
314	 * - ignore
315	 * - echo
316	 * - verbose
317	 * - die
318	 * - message
319	 * - log
320	 * - callback
321	 *
322	 * You may also set the error handling for several modes at once using PHP's bit operations.
323	 * Examples:
324	 * - E_ALL = Set the handling for all levels
325	 * - E_ERROR | E_WARNING = Set the handling for errors and warnings
326	 * - E_ALL ^ E_ERROR = Set the handling for all levels except errors
327	 *
328	 * @param   integer  $level    The error level for which to set the error handling
329	 * @param   string   $mode     The mode to use for the error handling.
330	 * @param   mixed    $options  Optional: Any options needed for the given mode.
331	 *
332	 * @return  mixed  True on success or a JException object if failed.
333	 *
334	 * @deprecated  12.1  Use PHP Exception
335	 * @since   11.1
336	 */
337	public static function setErrorHandling($level, $mode, $options = null)
338	{
339		JLog::add('JError::setErrorHandling() is deprecated.', JLog::WARNING, 'deprecated');
340
341		$levels = self::$levels;
342
343		$function = 'handle' . ucfirst($mode);
344
345		if (!is_callable(array('JError', $function)))
346		{
347			return self::raiseError(E_ERROR, 'JError:' . JERROR_ILLEGAL_MODE, 'Error Handling mode is not known', 'Mode: ' . $mode . ' is not implemented.');
348		}
349
350		foreach ($levels as $eLevel => $eTitle)
351		{
352			if (($level & $eLevel) != $eLevel)
353			{
354				continue;
355			}
356
357			// Set callback options
358			if ($mode == 'callback')
359			{
360				if (!is_array($options))
361				{
362					return self::raiseError(E_ERROR, 'JError:' . JERROR_ILLEGAL_OPTIONS, 'Options for callback not valid');
363				}
364
365				if (!is_callable($options))
366				{
367					$tmp = array('GLOBAL');
368					if (is_array($options))
369					{
370						$tmp[0] = $options[0];
371						$tmp[1] = $options[1];
372					}
373					else
374					{
375						$tmp[1] = $options;
376					}
377
378					return self::raiseError(
379						E_ERROR,
380						'JError:' . JERROR_CALLBACK_NOT_CALLABLE,
381						'Function is not callable',
382						'Function:' . $tmp[1] . ' scope ' . $tmp[0] . '.'
383					);
384				}
385			}
386
387			// Save settings
388			self::$handlers[$eLevel] = array('mode' => $mode);
389			if ($options != null)
390			{
391				self::$handlers[$eLevel]['options'] = $options;
392			}
393		}
394
395		return true;
396	}
397
398	/**
399	 * Method that attaches the error handler to JError
400	 *
401	 * @return  void
402	 *
403	 * @deprecated  12.1
404	 * @see     set_error_handler
405	 * @since   11.1
406	 */
407	public static function attachHandler()
408	{
409		JLog::add('JError::getErrorHandling() is deprecated.', JLog::WARNING, 'deprecated');
410
411		set_error_handler(array('JError', 'customErrorHandler'));
412	}
413
414	/**
415	 * Method that detaches the error handler from JError
416	 *
417	 * @return  void
418	 *
419	 * @deprecated  12.1
420	 * @see     restore_error_handler
421	 * @since   11.1
422	 */
423	public static function detachHandler()
424	{
425		JLog::add('JError::detachHandler() is deprecated.', JLog::WARNING, 'deprecated');
426
427		restore_error_handler();
428	}
429
430	/**
431	 * Method to register a new error level for handling errors
432	 *
433	 * This allows you to add custom error levels to the built-in
434	 * - E_NOTICE
435	 * - E_WARNING
436	 * - E_NOTICE
437	 *
438	 * @param   integer  $level    Error level to register
439	 * @param   string   $name     Human readable name for the error level
440	 * @param   string   $handler  Error handler to set for the new error level [optional]
441	 *
442	 * @return  boolean  True on success; false if the level already has been registered
443	 *
444	 * @deprecated  12.1
445	 * @since   11.1
446	 */
447	public static function registerErrorLevel($level, $name, $handler = 'ignore')
448	{
449		JLog::add('JError::registerErrorLevel() is deprecated.', JLog::WARNING, 'deprecated');
450
451		if (isset(self::$levels[$level]))
452		{
453			return false;
454		}
455
456		self::$levels[$level] = $name;
457		self::setErrorHandling($level, $handler);
458
459		return true;
460	}
461
462	/**
463	 * Translate an error level integer to a human readable string
464	 * e.g. E_ERROR will be translated to 'Error'
465	 *
466	 * @param   integer  $level  Error level to translate
467	 *
468	 * @return  mixed  Human readable error level name or boolean false if it doesn't exist
469	 *
470	 * @deprecated  12.1
471	 * @since   11.1
472	 */
473
474	public static function translateErrorLevel($level)
475	{
476		JLog::add('JError::translateErrorLevel() is deprecated.', JLog::WARNING, 'deprecated');
477
478		if (isset(self::$levels[$level]))
479		{
480			return self::$levels[$level];
481		}
482
483		return false;
484	}
485
486	/**
487	 * Ignore error handler
488	 * - Ignores the error
489	 *
490	 * @param   object  &$error   Exception object to handle
491	 * @param   array   $options  Handler options
492	 *
493	 * @return  object   The exception object
494	 *
495	 * @deprecated  12.1
496	 * @see     raise()
497	 * @since   11.1
498	 */
499	public static function handleIgnore(&$error, $options)
500	{
501		JLog::add('JError::handleIgnore() is deprecated.', JLog::WARNING, 'deprecated');
502
503		return $error;
504	}
505
506	/**
507	 * Echo error handler
508	 * - Echos the error message to output
509	 *
510	 * @param   object  &$error   Exception object to handle
511	 * @param   array   $options  Handler options
512	 *
513	 * @return  object  The exception object
514	 *
515	 * @deprecated  12.1
516	 * @see         raise()
517	 * @since       11.1
518	 */
519	public static function handleEcho(&$error, $options)
520	{
521		JLog::add('JError::handleEcho() is deprecated.', JLog::WARNING, 'deprecated');
522
523		$level_human = self::translateErrorLevel($error->get('level'));
524
525		// If system debug is set, then output some more information.
526		if (defined('JDEBUG'))
527		{
528			$backtrace = $error->getTrace();
529			$trace = '';
530			for ($i = count($backtrace) - 1; $i >= 0; $i--)
531			{
532				if (isset($backtrace[$i]['class']))
533				{
534					$trace .= sprintf("\n%s %s %s()", $backtrace[$i]['class'], $backtrace[$i]['type'], $backtrace[$i]['function']);
535				}
536				else
537				{
538					$trace .= sprintf("\n%s()", $backtrace[$i]['function']);
539				}
540
541				if (isset($backtrace[$i]['file']))
542				{
543					$trace .= sprintf(' @ %s:%d', $backtrace[$i]['file'], $backtrace[$i]['line']);
544				}
545			}
546		}
547
548		if (isset($_SERVER['HTTP_HOST']))
549		{
550			// Output as html
551			echo "<br /><b>jos-$level_human</b>: "
552				. $error->get('message') . "<br />\n"
553				. (defined('JDEBUG') ? nl2br($trace) : '');
554		}
555		else
556		{
557			// Output as simple text
558			if (defined('STDERR'))
559			{
560				fwrite(STDERR, "J$level_human: " . $error->get('message') . "\n");
561				if (defined('JDEBUG'))
562				{
563					fwrite(STDERR, $trace);
564				}
565			}
566			else
567			{
568				echo "J$level_human: " . $error->get('message') . "\n";
569				if (defined('JDEBUG'))
570				{
571					echo $trace;
572				}
573			}
574		}
575
576		return $error;
577	}
578
579	/**
580	 * Verbose error handler
581	 * - Echos the error message to output as well as related info
582	 *
583	 * @param   object  &$error   Exception object to handle
584	 * @param   array   $options  Handler options
585	 *
586	 * @return  object  The exception object
587	 *
588	 * @deprecated  12.1
589	 * @see         raise()
590	 * @since       11.1
591	 */
592	public static function handleVerbose(&$error, $options)
593	{
594		JLog::add('JError::handleVerbose() is deprecated.', JLog::WARNING, 'deprecated');
595
596		$level_human = self::translateErrorLevel($error->get('level'));
597		$info = $error->get('info');
598
599		if (isset($_SERVER['HTTP_HOST']))
600		{
601			// Output as html
602			echo "<br /><b>J$level_human</b>: " . $error->get('message') . "<br />\n";
603
604			if ($info != null)
605			{
606				echo "&#160;&#160;&#160;" . $info . "<br />\n";
607			}
608
609			echo $error->getBacktrace(true);
610		}
611		else
612		{
613			// Output as simple text
614			echo "J$level_human: " . $error->get('message') . "\n";
615			if ($info != null)
616			{
617				echo "\t" . $info . "\n";
618			}
619
620		}
621
622		return $error;
623	}
624
625	/**
626	 * Die error handler
627	 * - Echos the error message to output and then dies
628	 *
629	 * @param   object  &$error   Exception object to handle
630	 * @param   array   $options  Handler options
631	 *
632	 * @return  object  The exception object
633	 *
634	 * @deprecated  12.1
635	 * @see         raise()
636	 * @since       11.1
637	 */
638	public static function handleDie(&$error, $options)
639	{
640		JLog::add('JError::handleDie() is deprecated.', JLog::WARNING, 'deprecated');
641
642		$level_human = self::translateErrorLevel($error->get('level'));
643
644		if (isset($_SERVER['HTTP_HOST']))
645		{
646			// Output as html
647			jexit("<br /><b>J$level_human</b>: " . $error->get('message') . "<br />\n");
648		}
649		else
650		{
651			// Output as simple text
652			if (defined('STDERR'))
653			{
654				fwrite(STDERR, "J$level_human: " . $error->get('message') . "\n");
655				jexit();
656			}
657			else
658			{
659				jexit("J$level_human: " . $error->get('message') . "\n");
660			}
661		}
662
663		return $error;
664	}
665
666	/**
667	 * Message error handler
668	 * Enqueues the error message into the system queue
669	 *
670	 * @param   object  &$error   Exception object to handle
671	 * @param   array   $options  Handler options
672	 *
673	 * @return  object  The exception object
674	 *
675	 * @deprecated  12.1
676	 * @see         raise()
677	 * @since       11.1
678	 */
679	public static function handleMessage(&$error, $options)
680	{
681		JLog::add('JError::hanleMessage() is deprecated.', JLog::WARNING, 'deprecated');
682
683		$appl = JFactory::getApplication();
684		$type = ($error->get('level') == E_NOTICE) ? 'notice' : 'error';
685		$appl->enqueueMessage($error->get('message'), $type);
686
687		return $error;
688	}
689
690	/**
691	 * Log error handler
692	 * Logs the error message to a system log file
693	 *
694	 * @param   object  &$error   Exception object to handle
695	 * @param   array   $options  Handler options
696	 *
697	 * @return  object  The exception object
698	 *
699	 * @deprecated  12.1
700	 * @see         raise()
701	 * @since       11.1
702	 */
703	public static function handleLog(&$error, $options)
704	{
705		JLog::add('JError::handleLog() is deprecated.', JLog::WARNING, 'deprecated');
706
707		static $log;
708
709		if ($log == null)
710		{
711			$options['text_file'] = date('Y-m-d') . '.error.log';
712			$options['format'] = "{DATE}\t{TIME}\t{LEVEL}\t{CODE}\t{MESSAGE}";
713			JLog::addLogger($options, JLog::ALL, array('error'));
714		}
715
716		$entry = new JLogEntry(
717			str_replace(array("\r", "\n"), array('', '\\n'), $error->get('message')),
718			$error->get('level'),
719			'error'
720		);
721		$entry->code = $error->get('code');
722		JLog::add($entry);
723
724		return $error;
725	}
726
727	/**
728	 * Callback error handler
729	 * - Send the error object to a callback method for error handling
730	 *
731	 * @param   object  &$error   Exception object to handle
732	 * @param   array   $options  Handler options
733	 *
734	 * @return  object  The exception object
735	 *
736	 * @deprecated  12.1
737	 * @see         raise()
738	 * @since       11.1
739	 */
740	public static function handleCallback(&$error, $options)
741	{
742		JLog::add('JError::handleCallback() is deprecated.', JLog::WARNING, 'deprecated');
743
744		return call_user_func($options, $error);
745	}
746
747	/**
748	 * Display a custom error page and exit gracefully
749	 *
750	 * @param   object  &$error  Exception object
751	 *
752	 * @return  void
753	 *
754	 * @deprecated  12.1
755	 * @since   11.1
756	 */
757	public static function customErrorPage(&$error)
758	{
759		JLog::add('JError::customErrorPage() is deprecated.', JLog::WARNING, 'deprecated');
760
761		$app = JFactory::getApplication();
762		$document = JDocument::getInstance('error');
763		if ($document)
764		{
765			$config = JFactory::getConfig();
766
767			// Get the current template from the application
768			$template = $app->getTemplate();
769
770			// Push the error object into the document
771			$document->setError($error);
772
773			@ob_end_clean();
774			$document->setTitle(JText::_('Error') . ': ' . $error->get('code'));
775			$data = $document->render(false, array('template' => $template, 'directory' => JPATH_THEMES, 'debug' => $config->get('debug')));
776
777			// Failsafe to get the error displayed.
778			if (empty($data))
779			{
780				self::handleEcho($error, array());
781			}
782			else
783			{
784				// Do not allow cache
785				JResponse::allowCache(false);
786
787				JResponse::setBody($data);
788				echo JResponse::toString();
789			}
790		}
791		else
792		{
793			// Just echo the error since there is no document
794			// This is a common use case for Command Line Interface applications.
795			self::handleEcho($error, array());
796		}
797		$app->close(0);
798	}
799
800	/**
801	 * Display a message to the user
802	 *
803	 * @param   integer  $level  The error level - use any of PHP's own error levels
804	 *                   for this: E_ERROR, E_WARNING, E_NOTICE, E_USER_ERROR,
805	 *                   E_USER_WARNING, E_USER_NOTICE.
806	 * @param   string   $msg    Error message, shown to user if need be.
807	 *
808	 * @return  void
809	 *
810	 * @deprecated  12.1
811	 * @since   11.1
812	 */
813	public static function customErrorHandler($level, $msg)
814	{
815		JLog::add('JError::customErrorHandler() is deprecated.', JLog::WARNING, 'deprecated');
816
817		self::raise($level, '', $msg);
818	}
819
820	/**
821	 * Render the backtrace
822	 *
823	 * @param   integer  $error  The error
824	 *
825	 * @return  string  Contents of the backtrace
826	 *
827	 * @deprecated  12.1
828	 * @since   11.1
829	 */
830	public static function renderBacktrace($error)
831	{
832		JLog::add('JError::renderBacktrace() is deprecated.', JLog::WARNING, 'deprecated');
833
834		$contents = null;
835		$backtrace = $error->getTrace();
836
837		if (is_array($backtrace))
838		{
839			ob_start();
840			$j = 1;
841			echo '<table cellpadding="0" cellspacing="0" class="Table">';
842			echo '		<tr>';
843			echo '				<td colspan="3" class="TD"><strong>Call stack</strong></td>';
844			echo '		</tr>';
845			echo '		<tr>';
846			echo '				<td class="TD"><strong>#</strong></td>';
847			echo '				<td class="TD"><strong>Function</strong></td>';
848			echo '				<td class="TD"><strong>Location</strong></td>';
849			echo '		</tr>';
850
851			for ($i = count($backtrace) - 1; $i >= 0; $i--)
852			{
853				echo '		<tr>';
854				echo '				<td class="TD">' . $j . '</td>';
855
856				if (isset($backtrace[$i]['class']))
857				{
858					echo '		<td class="TD">' . $backtrace[$i]['class'] . $backtrace[$i]['type'] . $backtrace[$i]['function'] . '()</td>';
859				}
860				else
861				{
862					echo '		<td class="TD">' . $backtrace[$i]['function'] . '()</td>';
863				}
864
865				if (isset($backtrace[$i]['file']))
866				{
867					echo '				<td class="TD">' . $backtrace[$i]['file'] . ':' . $backtrace[$i]['line'] . '</td>';
868				}
869				else
870				{
871					echo '				<td class="TD">&#160;</td>';
872				}
873
874				echo '		</tr>';
875				$j++;
876			}
877
878			echo '</table>';
879			$contents = ob_get_contents();
880			ob_end_clean();
881		}
882
883		return $contents;
884	}
885}