Skip to content

Make 404 a exception instead of a response #115

@edgardcunha

Description

@edgardcunha

Using exception handling we can make errors catchable by type. If we treat the error as an usual route we can also attach routines to it so it can respect content negotiation (as mentioned on #109).

  • Throw Respect\Rest\Exception\Http\NotFound exception for 404 errors instead of just sending a header.
  • Create a default route to catch this exception, ensuring current behaviour is not affected.

Original issue content

I have a question about how to implement a error route for a Default 404 Not Found Page, but have not found the solution.
I created a class Error404 controller to display a standard html page, but it did not work:
$router->any('/**', 'Routes\Error404');
I also tried to use the method errorRoute, but without success.
$router->errorRoute($callback);
Is there a solution to this problem?

Thank's all to help me!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions