1 | <?php |
||
51 | class ErrorAction extends Action |
||
52 | { |
||
53 | /** |
||
54 | * @var string the view file to be rendered. If not set, it will take the value of [[id]]. |
||
55 | * That means, if you name the action as "error" in "SiteController", then the view name |
||
56 | * would be "error", and the corresponding view file would be "views/site/error.php". |
||
57 | */ |
||
58 | public $view; |
||
59 | /** |
||
60 | * @var string the name of the error when the exception name cannot be determined. |
||
61 | * Defaults to "Error". |
||
62 | */ |
||
63 | public $defaultName; |
||
64 | /** |
||
65 | * @var string the message to be displayed when the exception message contains sensitive information. |
||
66 | * Defaults to "An internal server error occurred.". |
||
67 | */ |
||
68 | public $defaultMessage; |
||
69 | /** |
||
70 | * @var \Exception the exception object, normally is filled on [[init()]] method call. |
||
71 | * @see [[findException()]] to know default way of obtaining exception. |
||
72 | * @since 2.0.11 |
||
73 | */ |
||
74 | protected $exception; |
||
75 | |||
76 | /** |
||
77 | * {@inheritdoc} |
||
78 | */ |
||
79 | public function init() |
||
91 | |||
92 | /** |
||
93 | * Runs the action. |
||
94 | * |
||
95 | * @return string result content |
||
96 | */ |
||
97 | public function run() |
||
105 | |||
106 | /** |
||
107 | * Builds string that represents the exception. |
||
108 | * Normally used to generate a response to AJAX request. |
||
109 | * @return string |
||
110 | * @since 2.0.11 |
||
111 | */ |
||
112 | protected function renderAjaxResponse() |
||
116 | |||
117 | /** |
||
118 | * Renders a view that represents the exception. |
||
119 | * @return string |
||
120 | * @since 2.0.11 |
||
121 | */ |
||
122 | protected function renderHtmlResponse() |
||
126 | |||
127 | /** |
||
128 | * Builds array of parameters that will be passed to the view. |
||
129 | * @return array |
||
130 | * @since 2.0.11 |
||
131 | */ |
||
132 | protected function getViewRenderParams() |
||
140 | |||
141 | /** |
||
142 | * Gets exception from the [[yii\web\ErrorHandler|ErrorHandler]] component. |
||
143 | * In case there is no exception in the component, treat as the action has been invoked |
||
144 | * not from error handler, but by direct route, so '404 Not Found' error will be displayed. |
||
145 | * @return \Exception |
||
146 | * @since 2.0.11 |
||
147 | */ |
||
148 | protected function findException() |
||
156 | |||
157 | /** |
||
158 | * Gets the code from the [[exception]]. |
||
159 | * @return mixed |
||
160 | * @since 2.0.11 |
||
161 | */ |
||
162 | protected function getExceptionCode() |
||
170 | |||
171 | /** |
||
172 | * Returns the exception name, followed by the code (if present). |
||
173 | * |
||
174 | * @return string |
||
175 | * @since 2.0.11 |
||
176 | */ |
||
177 | protected function getExceptionName() |
||
191 | |||
192 | /** |
||
193 | * Returns the [[exception]] message for [[yii\base\UserException]] only. |
||
194 | * For other cases [[defaultMessage]] will be returned. |
||
195 | * @return string |
||
196 | * @since 2.0.11 |
||
197 | */ |
||
198 | protected function getExceptionMessage() |
||
206 | } |
||
207 |