[FEATURE] Create an Exception hierarchy for HTTP Status Exceptions
[Packages/TYPO3.CMS.git] / t3lib / error / http / class.t3lib_error_http_statusexception.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2011 Steffen Gebert <steffen.gebert@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 * HTTP Status Exception
27 *
28 * @author Steffen Gebert <steffen.gebert@typo3.org>
29 * @package TYPO3
30 * @subpackage error
31 */
32 class t3lib_error_http_StatusException extends t3lib_error_Exception {
33
34 /**
35 * @var array HTTP Status Header lines
36 */
37 protected $statusHeaders;
38
39 /**
40 * @var string Title of the message
41 */
42 protected $title = 'Oops, an error occurred!';
43
44 /**
45 * Constructor for this Status Exception
46 *
47 * @param string|array $statusHeaders HTTP Status header line(s)
48 * @param string $title Title of the error message
49 * @param string $message Error Message
50 * @param int $code Exception Code
51 */
52 public function __construct($statusHeaders, $message, $title = '', $code = 0) {
53 if (is_array($statusHeaders)) {
54 $this->statusHeaders = $statusHeaders;
55 } else {
56 $this->statusHeaders = array($statusHeaders);
57 }
58 $this->title = $title ? $title : $this->title;
59 parent::__construct($message, $code);
60 }
61
62 /**
63 * Setter for the title.
64 *
65 * @param string $title
66 * @return void
67 */
68 public function setTitle($title) {
69 $this->title = $title;
70 }
71
72 /**
73 * Getter for the title.
74 *
75 * @return string
76 */
77 public function getTitle() {
78 return $this->title;
79 }
80
81 /**
82 * Getter for the Status Header.
83 *
84 * @return string
85 */
86 public function getStatusHeaders() {
87 return $this->statusHeaders;
88 }
89 }
90
91 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/error/t3lib_error_http_statusexception'])) {
92 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/error/t3lib_error_http_statusexception']);
93 }
94
95 ?>