Welcome Guest, Not a member yet? Register   Sign In
early exit of the controller causes blank page
#1

[eluser]Unknown[/eluser]
Hi all,

When I put an exit() right after loading a view, I get a blank page. Anybody knows what might cause this?

The use case is i don't use the show_error() function provided by CI. I have my own to show an error w/ the same template as the rest of the app. If the controller execute normally it would render the designated template, but if we have some exception, it should render the customized error page and exit. Putting the exit right after the load $this->load->view() result into a blank page instead.

Does the controller has some unfinished tasks to wrap up? What is then a good way to abort the program and after showing an pretty error and performs some error logging.

Thanks
#2

[eluser]louis w[/eluser]
I would suggest setting the $this->output->final_output to whatever you want to output and then doing a simple return; statement to halt your controller method from progressing. CI does not output anything to the browser until the application is done processing, doing and exit() stops your app from completing.

Even better yet, you should just try editing the error pages. Thats what I did. I check to see if i can do a get_instance() to get the CI super object and if so I draw the error page with my custom templating engine. If not the I proceed to the normal error page.




Theme © iAndrew 2016 - Forum software by © MyBB