-
Notifications
You must be signed in to change notification settings - Fork 75
/
Exception.php
60 lines (52 loc) · 1.11 KB
/
Exception.php
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
<?php
/**
* Basic minion exception class.
*
* @package Kohana/Minion
* @category Exception
* @author Kohana Team
* @copyright (c) 2009-2014 Kohana Team
* @license http://kohanaframework.org/license
*/
abstract class Kohana_Minion_Exception extends Kohana_Exception {
/**
* Inline exception handler, displays the error message,
* source of the exception, and the stack trace of the error.
*
* @param mixed $e
* @return bool
*/
public static function handler($e)
{
try
{
// Log the exception
Kohana_Exception::log($e);
$text = $e instanceof Minion_Exception ? $e->_cli_format() : parent::text($e);
fwrite(STDERR, $text.PHP_EOL);
$exit_code = $e->getCode();
// Never exit '0' after an exception.
if ($exit_code == 0)
{
$exit_code = 1;
}
exit($exit_code);
}
catch (Exception $e)
{
// Display the exception text
fwrite(STDERR, parent::text($e).PHP_EOL);
// Exit with an error status
exit(1);
}
}
/**
* Formating error message for display in CLI.
*
* @return string
*/
protected function _cli_format()
{
return parent::text($this);
}
}