1 | <?php |
||
28 | class ExceptionStrategy extends AbstractListenerAggregate |
||
29 | { |
||
30 | /** |
||
31 | * Display exceptions? |
||
32 | * @var bool |
||
33 | */ |
||
34 | protected $displayExceptions = false; |
||
35 | |||
36 | /** |
||
37 | * Default Exception Message |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $defaultExceptionMessage = "Oh no. Something went wrong, but we have been notified.\n"; |
||
41 | |||
42 | /** |
||
43 | * A template for message to show in console when an exception has occurred. |
||
44 | * @var string|callable |
||
45 | */ |
||
46 | protected $message = <<<EOT |
||
47 | ====================================================================== |
||
48 | The application has thrown an exception! |
||
49 | ====================================================================== |
||
50 | :className |
||
51 | :message |
||
52 | ---------------------------------------------------------------------- |
||
53 | :file::line |
||
54 | :stack |
||
55 | ====================================================================== |
||
56 | Previous Exception(s): |
||
57 | ====================================================================== |
||
58 | :previous |
||
59 | |||
60 | EOT; |
||
61 | |||
62 | /** |
||
63 | * {@inheritDoc} |
||
64 | */ |
||
65 | public function attach(EventManagerInterface $events, $priority = 1) |
||
70 | |||
71 | /** |
||
72 | * Flag: display exceptions in error pages? |
||
73 | * |
||
74 | * @param bool $displayExceptions |
||
75 | * @return ExceptionStrategy |
||
76 | */ |
||
77 | public function setDisplayExceptions($displayExceptions) |
||
82 | |||
83 | /** |
||
84 | * Should we display exceptions in error pages? |
||
85 | * |
||
86 | * @return bool |
||
87 | */ |
||
88 | public function displayExceptions() |
||
92 | |||
93 | /** |
||
94 | * Get current template for message that will be shown in Console. |
||
95 | * |
||
96 | * @return string |
||
1 ignored issue
–
show
|
|||
97 | */ |
||
98 | public function getMessage() |
||
102 | |||
103 | /** |
||
104 | * Set the default exception message |
||
105 | * @param string $defaultExceptionMessage |
||
106 | * @return self |
||
107 | */ |
||
108 | public function setDefaultExceptionMessage($defaultExceptionMessage) |
||
113 | |||
114 | /** |
||
115 | * Set template for message that will be shown in Console. |
||
116 | * The message can be a string (template) or a callable (i.e. a closure). |
||
117 | * |
||
118 | * The closure is expected to return a string and will be called with 2 parameters: |
||
119 | * Exception $exception - the exception being thrown |
||
120 | * boolean $displayExceptions - whether to display exceptions or not |
||
121 | * |
||
122 | * If the message is a string, one can use the following template params: |
||
123 | * |
||
124 | * :className - full class name of exception instance |
||
125 | * :message - exception message |
||
126 | * :code - exception code |
||
127 | * :file - the file where the exception has been thrown |
||
128 | * :line - the line where the exception has been thrown |
||
129 | * :stack - full exception stack |
||
130 | * |
||
131 | * @param string|callable $message |
||
132 | * @return ExceptionStrategy |
||
133 | */ |
||
134 | public function setMessage($message) |
||
139 | |||
140 | /** |
||
141 | * Create an exception view model, and set the console status code |
||
142 | * |
||
143 | * @param MvcEvent $e |
||
144 | * @return void |
||
145 | */ |
||
146 | public function prepareExceptionViewModel(MvcEvent $e) |
||
216 | } |
||
1 ignored issue
–
show
|
|||
217 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.