-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.php
More file actions
67 lines (60 loc) · 1.82 KB
/
errors.php
File metadata and controls
67 lines (60 loc) · 1.82 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
require_once __DIR__ . '/../config.php';
require_once __DIR__ . '/../lib/handler.php';
/**
* default 404 controller
*/
class FourOhFourHandler extends BaseHandler {
protected $_messages = [
"what chu doin'?",
"you doing wayyy too much rn",
"😬",
"👀",
];
protected $_template = '404.html';
protected $_status_code = 404;
public function get(){
$i = array_rand($this->_messages);
$message = $this->_messages[$i];
$four = $this->load($this->_template, ['message' => $message]);
return $this->page($four, $this->_status_code, [], $this->_status_code);
}
}
class FiveOhOhHandler extends FourOhFourHandler {
protected $_messages = [
'internal server error',
'yo, what did you do?',
];
protected $_template = '500.html';
protected $_status_code = 500;
private function exceptionToSlack(){
ob_start();
var_dump($this->exception);
$exc = ob_get_clean();
$headers = [
'Content-type' => 'application/json',
];
$post = [
'text' => '500',
'attachments' => [
[
'pretext' => 'there was a 500 on the DATCODE site',
'fields' => [
[
'title' => 'Exception trace',
'value' => $exc,
'short' => false
],
]
]
]
];
$url = sprintf('https://hooks.slack.com/services/%s', $this->getConfig('slack_admin_webhook'));
$post = json_encode($post);
$this->callAPI('POST', $url, $post, $headers);
}
public function get(){
$this->exceptionToSlack();
return parent::get();
}
}