-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy patherr.php
More file actions
48 lines (41 loc) · 1.2 KB
/
err.php
File metadata and controls
48 lines (41 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/** This file is part of load.link (https://github.com/deuiore/load.link).
* View the LICENSE file for full license information.
**/
class Err extends Exception
{
const FATAL = 'error fatal';
const FORBIDDEN = 'error forbidden';
const NOT_FOUND = 'error not_found';
const WARNING = 'error warning';
protected static $default_title = array(
self::FATAL => 'Error',
self::FORBIDDEN => 'Access Denied',
self::NOT_FOUND => 'Not Found',
self::WARNING => 'Warning',
);
protected $msg;
protected $type;
public function __construct($type = self::FATAL, $message = '',
$redirect = NULL)
{
$this->msg = new Message($type, $message, $redirect);
$this->msg->setTitle(self::$default_title[$type]);
$this->type = $type;
parent::__construct($message);
}
public function getPage()
{
$page = $this->msg->getPage();
switch ($this->type)
{
case self::FORBIDDEN:
$page->setResponseCode(403);
break;
case self::NOT_FOUND:
$page->setResponseCode(404);
break;
}
return $page;
}
}