$this->response->body = View::factory('errors/mine');
return;
will do the trick quite nicely.
Note that CodeIgniter has a pretty straitforward front-to-back flow, so you can easily break out and stop. Fuel is more event driven, the fact that you stop a controller from execution doesn't stop everything around it (although this works fine for a main request).
If you feel an extension of the error class is needed, please create a feature request at http://github.com/fuel/core/issues, explaining your reasons for wanting this feature. throw new Request404Exception();
throw new Request404Exception('views/this/that');
// Generate the request, execute it and send the output.
try
{
$response = Request::factory()->execute()->response();
}
catch (Request404Exception $e)
{
if ($e->getMessage() == '')
{
if ($route = Config::get('routes._404_'))
{
$response = Request::factory($route)->execute()->response();
}
else
{
throw $e;
}
}
else
{
$response = new \Response(\View::factory($e->getMessage()), 500);
}
}
<?php
class ApplicationException extends Exception {
/**
* Process the application error
*
* @return void
*/
public function handle()
{
ob_end_clean();
echo \View::factory('errors/application', array('exception' => $this), false);
}
}
<?php
if ($m = $exception->getMessage())
{
echo $m;
}
else
{
echo "Put a generic error message here";
}
throw new ApplicationException('any message you want to pass');
//$response = Request::factory()->execute()->response();
/* FROM 1.1 */
// Generate the request, execute it and send the output.
try
{
$response = Request::factory()->execute()->response();
}
catch (Request404Exception $e)
{
if ($route = Config::get('routes._404_'))
{
$response = Request::factory($route)->execute()->response();
}
else
{
throw $e;
}
}
/* BY PROGRAMMIERAFFE */
catch (ApplicationException $e)
{
$response = ApplicationException::handle($e);
}
/* EO BY PROGRAMMIERAFFE */
/* EO FROM 1.1 */
<?php
class ApplicationException extends Exception {
/**
* Process the application error
*
* @return response
*/
public function handle($e)
{
ob_end_clean();
return new \Response(\View::factory('errors/application',array('exception' => $e),false), 500);
}
}
ErrorException [ Notice ]: ob_end_flush() [ref.outcontrol]: failed to delete and flush buffer. No buffer to delete or flush.
// only clean the buffer if it has any data in it ob_end_length() and ob_end_clean();
// throw a normal text error
throw new ApplicationException('this is a standard error');
// throw a json text error
throw new ApplicationException('this is a standard error', 1);
It looks like you're new here. If you want to get involved, click one of these buttons!