724b209e1c946b1bddb2badef6fb7ba30daa7c51
[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 // we use a nice-looking title for our visitors instead of the exception's class name
57 $messageObj = t3lib_div::makeInstance('t3lib_message_ErrorPageMessage', $exception->getMessage(), 'Oops, an error occured!');
58 $messageObj->output();
59 }
60
61 /**
62 * Echoes an exception for the command line.
63 *
64 * @param Exception $exception The exception
65 * @return void
66 */
67 public function echoExceptionCLI(Exception $exception) {
68 $this->writeLogEntries($exception, self::CONTEXT_CLI);
69 exit(1);
70 }
71 }
72
73 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/error/class.t3lib_error_productionexceptionhandler.php'])) {
74 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/error/class.t3lib_error_productionexceptionhandler.php']);
75 }
76
77 ?>