Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elmer\Router should have support for custom http error handlers #8

Open
peterhorne opened this issue May 5, 2012 · 1 comment
Open
Milestone

Comments

@peterhorne
Copy link
Owner

For example:

  <?php
    $app->error(404, function() {
        return array(404, 'Page not found');
    });

Which can then be called inside a route:

  <?php
    $app->get('/', function($app) {
        return $app->error(404);
    });
@peterhorne
Copy link
Owner Author

An alternative is to provide implement this as a filter that checks the status code of the response. Example:

<?php
use Elmer\Filters\ErrorHandler;

$errors = new ErrorHandler;
$errors[404] = function($app) {
  return array(404, 'Custom error message');
});

$app->filter($errors);

Routes return a status code with no knowledge of the error handler filter

<?php
$routes->get('/', function($app) {
  return 404;
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant