Skip to content

Commit 7bf4326

Browse files
committed
Exception rendering improvement.
1 parent 8822811 commit 7bf4326

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Action.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,24 +178,34 @@ protected function renderException($exception) {
178178
'message' => $exception->getMessage(),
179179
];
180180

181+
$data = false;
181182
if (YII_DEBUG) {
182-
$result['data'] = [
183+
$data = [
183184
'type' => get_class($exception)
184185
];
185186
if (!$exception instanceof UserException) {
186-
$result['data'] += [
187+
$data += [
187188
'file' => $exception->getFile(),
188189
'line' => $exception->getLine(),
189190
'stack-trace' => explode("\n", $exception->getTraceAsString())
190191
];
191192

192193
if ($exception instanceof \yii\db\Exception) {
193-
$result['data']['error-info'] = $exception->errorInfo;
194+
$data['error-info'] = $exception->errorInfo;
194195
}
195196
}
196197
}
197198
if (($prev = $exception->getPrevious()) !== null) {
198-
$result['data']['previous'] = $this->renderException($prev);
199+
$data['previous'] = $this->renderException($prev);
200+
}
201+
202+
if ($data) {
203+
if ($exception instanceof JsonRpcException) {
204+
$result['data'] = $data;
205+
}
206+
else {
207+
$result += $data;
208+
}
199209
}
200210

201211
return $result;

0 commit comments

Comments
 (0)