[FEATURE] Link Exception messages to Wiki pages
[Packages/TYPO3.CMS.git] / t3lib / error / class.t3lib_error_productionexceptionhandler.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009-2011 Ingo Renner <ingo@typo3.org>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25
26 /**
27 * A quite exception handler which catches but ignores any exception.
28 *
29 * This file is a backport from FLOW3
30 *
31 * @package TYPO3
32 * @subpackage t3lib_error
33 */
34 class t3lib_error_ProductionExceptionHandler extends t3lib_error_AbstractExceptionHandler {
35
36 /**
37 * Constructs this exception handler - registers itself as the default exception handler.
38 *
39 * @author Robert Lemke <robert@typo3.org>
40 */
41 public function __construct() {
42 set_exception_handler(array($this, 'handleException'));
43 }
44
45 /**
46 * Echoes an exception for the web.
47 *
48 * @param Exception $exception The exception
49 * @return void
50 */
51 public function echoExceptionWeb(Exception $exception) {
52 if (!headers_sent()) {
53 header("HTTP/1.1 500 Internal Server Error");
54 }
55 $this->writeLogEntries($exception, self::CONTEXT_WEB);
56
57 if ($exception->getCode() > 0) {
58 $moreInformationLink = '<p>More information regarding this error might be available <a href="'
59 . TYPO3_URL_EXCEPTION . $exception->getCode() . '" target="_blank">online</a>.</p>';
60 } else {
61 $moreInformationLink = '';
62 }
63
64 // we use a nice-looking title for our visitors instead of the exception's class name
65 $messageObj = t3lib_div::makeInstance('t3lib_message_ErrorPageMessage', $exception->getMessage() . $moreInformationLink, 'Oops, an error occured!');
66 $messageObj->output();
67 }
68
69 /**
70 * Echoes an exception for the command line.
71 *
72 * @param Exception $exception The exception
73 * @return void
74 */
75 public function echoExceptionCLI(Exception $exception) {
76 $this->writeLogEntries($exception, self::CONTEXT_CLI);
77 exit(1);
78 }
79 }
80
81 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/error/class.t3lib_error_productionexceptionhandler.php'])) {
82 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/error/class.t3lib_error_productionexceptionhandler.php']);
83 }
84
85 ?>