R
R
romany42016-08-05 10:09:53
Yii
romany4, 2016-08-05 10:09:53

How to create a single point of exception handling?

Input
- Template advance.
- Looking at the rest section (others - backend, frontend...)
How to create a single point of exception handling
i.e. so that in each action of each controller do not write a try.. catch block

try {
  // блок кода
  $request = Yii::$app->request->notExistedParamForException;
  return ['key' => 'test'];
} catch (\Exception $e) {
  // блок отлова ошибки и вывода соответствующего отображения
  return $this->run('/common/error/500', ['e' => $e]);
}

but a simple option
$request = Yii::$app->request->notExistedParamForException;
return ['key' => 'test'];

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2016-08-05
@romany4

And what prevents you from using the standard errorHandler ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question