Different views for errors

Hello! I want to display bootstrap alert, but not always with ‘danger’ class.

I am wondering is there possibility to set different views for handled exceptions in easy way? Or I should extend Exception class, add property $type, method getType() and override constructor for eg. NotFoundHttpException?


I use

<?= common\widgets\Alert::widget() ?>

in my view and from controller I set flash like this

Yii::$app->session->setFlash('warning', 'blablabla');

Changing the first parameter with error, success etc you can change bootstrap alert.


Hello andrzej1_1,

For better understanding, because I have the feeling you’re mixing things up a littlebit:

Are you talking about application exceptions?

Or about custom flash-messages like mentioned by minitia?

Have you already read documentation and guide?

About Exceptions and Views:


About Session Flash Data:


Hope this helps.

Best Regards