2
2
/**
3
3
* @package at.exceptable
4
4
* @author Adrian <adrian@enspi.red>
5
- * @copyright 2014 - 2016
5
+ * @copyright 2014 - 2018
6
6
* @license GPL-3.0 (only)
7
7
*
8
8
* This program is free software: you can redistribute it and/or modify it
32
32
* exceptable::getSeverity() will need to be aliased when the trait is used.
33
33
* - implementations cannot extend from PDOException,
34
34
* because it breaks the Throwable interface (its getCode() returns a string).
35
- *
36
- * @method string Throwable::__toString( void )
37
- * @method int Throwable::getCode( void )
38
- * @method string Throwable::getFile( void )
39
- * @method int Throwable::getLine( void )
40
- * @method string Throwable::getMessage( void )
41
- * @method Throwable Throwable::getPrevious( void )
42
- * @method array Throwable::getTrace( void )
43
- * @method string Throwable::getTraceAsString( void )
44
35
*/
45
- interface Exceptable extends \ Throwable {
36
+ interface Exceptable extends Throwable {
46
37
47
38
/**
48
39
* exception severity levels.
@@ -55,53 +46,30 @@ interface Exceptable extends \Throwable {
55
46
const WARNING = E_WARNING ;
56
47
const NOTICE = E_NOTICE ;
57
48
58
- /**
59
- * default info for unknown/generic exception cases.
60
- *
61
- * @type int DEFAULT_CODE
62
- * @type int DEFAULT_MESSAGE
63
- * @type int DEFAULT_SEVERITY
64
- */
65
- const DEFAULT_CODE = 0 ;
66
- const DEFAULT_MESSAGE = '' ;
67
- const DEFAULT_SEVERITY = self ::ERROR ;
68
-
69
49
/**
70
50
* gets information about a code known to the implementing class.
71
51
*
72
- * @param int $code the exception code to look up
73
- * @throws ExceptableException if the code is not known to the implementation
74
- * @return array a map of info about the code,
75
- * including (at a minimum) its "code", "severity", and "message".
52
+ * @param int $code the exception code to look up
53
+ * @throws Exceptable if the code is not known to the implementation
54
+ * @return array a map of info about the error condition
76
55
*/
77
- public static function get_info (int $ code ) : array ;
56
+ public static function getInfo (int $ code ) : array ;
78
57
79
58
/**
80
59
* checks whether the implementation has info about the given code.
81
60
*
82
61
* @param int $code the code to check
83
62
* @return bool true if the code is known; false otherwise
84
63
*/
85
- public static function has_info (int $ code ) : bool ;
64
+ public static function hasInfo (int $ code ) : bool ;
86
65
87
66
/**
88
- * @param string $0 exception message
89
- * if omitted, a message must be set based on the exception code
90
- * @param int $1 exception code
91
- * if omitted, a default code must be set
92
- * @param Throwable $2 previous exception
93
- * @param array $3 additional exception context
94
- * @throws ExceptableException if argument(s) are invalid
67
+ * @param int $code exception code
68
+ * @param array $context additional exception context
69
+ * @param Throwable $previous previous exception
70
+ * @throws ExceptableException if code is invalid
95
71
*/
96
- public function __construct (...$ args );
97
-
98
- /**
99
- * adds contextual info to this exception.
100
- *
101
- * @param array $context map of info to add
102
- * @return $this
103
- */
104
- public function addContext (array $ context ) : Exceptable ;
72
+ public function __construct (int $ code , array $ context = [], Throwable $ previous = null );
105
73
106
74
/**
107
75
* gets contextual info about this exception.
@@ -115,42 +83,12 @@ public function getContext() : array;
115
83
*
116
84
* @return Throwable the root exception
117
85
*/
118
- public function getRoot () : \ Throwable ;
86
+ public function getRoot () : Throwable ;
119
87
120
88
/**
121
89
* gets exception severity.
122
90
*
123
91
* @return int the exception severity
124
92
*/
125
93
public function getSeverity () : int ;
126
-
127
- /**
128
- * checks the exception severity.
129
- *
130
- * @return bool true if exception severity is "Error"; false otherwise
131
- */
132
- public function isError () : bool ;
133
-
134
- /**
135
- * checks the exception severity.
136
- *
137
- * @return bool true if exception severity is "Warning"; false otherwise
138
- */
139
- public function isWarning () : bool ;
140
-
141
- /**
142
- * checks the exception severity.
143
- *
144
- * @return bool true if exception severity is "Notice"; false otherwise
145
- */
146
- public function isNotice () : bool ;
147
-
148
- /**
149
- * adds contextual info to this exception.
150
- *
151
- * @param int $severity one of Exceptable::ERROR|WARNING|NOTICE
152
- * @throws ExceptableException if severity is invalid
153
- * @return $this
154
- */
155
- public function setSeverity (int $ severity ) : Exceptable ;
156
94
}
0 commit comments