[CLEANUP] Error handling classes
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Error / Http / StatusException.php
1 <?php
2 namespace TYPO3\CMS\Core\Error\Http;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2011-2013 Steffen Gebert <steffen.gebert@typo3.org>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26 /**
27 * HTTP Status Exception
28 *
29 * @author Steffen Gebert <steffen.gebert@typo3.org>
30 */
31 class StatusException extends \TYPO3\CMS\Core\Error\Exception {
32
33 /**
34 * @var array HTTP Status Header lines
35 */
36 protected $statusHeaders;
37
38 /**
39 * @var string Title of the message
40 */
41 protected $title = 'Oops, an error occurred!';
42
43 /**
44 * Constructor for this Status Exception
45 *
46 * @param string|array $statusHeaders HTTP Status header line(s)
47 * @param string $title Title of the error message
48 * @param string $message Error Message
49 * @param int $code Exception Code
50 */
51 public function __construct($statusHeaders, $message, $title = '', $code = 0) {
52 if (is_array($statusHeaders)) {
53 $this->statusHeaders = $statusHeaders;
54 } else {
55 $this->statusHeaders = array($statusHeaders);
56 }
57 $this->title = $title ?: $this->title;
58 parent::__construct($message, $code);
59 }
60
61 /**
62 * Setter for the title.
63 *
64 * @param string $title
65 * @return void
66 */
67 public function setTitle($title) {
68 $this->title = $title;
69 }
70
71 /**
72 * Getter for the title.
73 *
74 * @return string
75 */
76 public function getTitle() {
77 return $this->title;
78 }
79
80 /**
81 * Getter for the Status Header.
82 *
83 * @return string
84 */
85 public function getStatusHeaders() {
86 return $this->statusHeaders;
87 }
88
89 }