how can I embed thrown Exception into themed main layout?
As I understand, thrown exception will not render main layouts, right?
Normal page has following processing workflow:
protected/views/cms/my-existing-view.php
protected/views/layouts/column2.php
protected/views/layouts/main.php
However, Exceptions will only process:
protected/views/cms/error-page.php
protected/views/layouts/column2.php
Is there any way to embed thrown exception into nice layout from file
[protected/views/layouts/main.php]
with header code 404?
I would like to avoid maintaining duplicate layout files - one for normal files and one for exceptions.
Thank you in advance for any advices.
PS:
I have read guide on handling exceptions, but this did not help much,
since I know how to configure custom exceptions handling, but I would like to have it regularly embedded into
common main layout file. It seems to me that since 1.1.5 there is new parameter $exit in CApplication::end($status=0, $exit=true), which could solve the issue by setting it to $exit=false to continue rendering, but I dont know how can I control it…
In order to solve this issue, i have created a view specifically created to render errors, and then (due to the ajaxed nature of my cms) call its rendering by renderPartial with its return parameter set to true. Then I flush its result and end the response.
Imagine it is not ajax… ok? Imagine that, in your rendered view, you check for specific value
if($error != false)
// display error
Then you could do try and catch and if catch set the $error value to the error message you wish to display. At the end of the action you render the file providing the $error variable with it. I don’t think is a problem with it.
I am developing quite a big application at the moment, and I have inserted a function within the Controller component from where all controllers extend from. It actually formats the error message and returns to the caller. How hard is to maintain that function in the long term?
Here an example:
public function notify($message = ‘’, $type = ‘success’, $return = false){