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?

Anyone?

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.

Mattia

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:

http://www.yiiframework.com/doc-2.0/guide-runtime-handling-errors.html#customizing-error-display

About Session Flash Data:

http://www.yiiframework.com/doc-2.0/guide-runtime-sessions-cookies.html#flash-data

Hope this helps.

Best Regards