{"action":"created","issue":{"url":"https://api.github.com/repos/nikic/FastRoute/issues/41","labels_url":"https://api.github.com/repos/nikic/FastRoute/issues/41/labels{/name}","comments_url":"https://api.github.com/repos/nikic/FastRoute/issues/41/comments","events_url":"https://api.github.com/repos/nikic/FastRoute/issues/41/events","html_url":"https://github.com/nikic/FastRoute/issues/41","id":66832419,"number":41,"title":"Conditional error handlers","user":{"login":"vlakarados","id":386678,"avatar_url":"https://avatars.githubusercontent.com/u/386678?v=3","gravatar_id":"","url":"https://api.github.com/users/vlakarados","html_url":"https://github.com/vlakarados","followers_url":"https://api.github.com/users/vlakarados/followers","following_url":"https://api.github.com/users/vlakarados/following{/other_user}","gists_url":"https://api.github.com/users/vlakarados/gists{/gist_id}","starred_url":"https://api.github.com/users/vlakarados/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vlakarados/subscriptions","organizations_url":"https://api.github.com/users/vlakarados/orgs","repos_url":"https://api.github.com/users/vlakarados/repos","events_url":"https://api.github.com/users/vlakarados/events{/privacy}","received_events_url":"https://api.github.com/users/vlakarados/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-07T09:08:56Z","updated_at":"2015-04-07T12:33:37Z","closed_at":null,"body":"Currently there are only two errors: method not allowed and not found.\r\n\r\nI understand that FastRoute doesn't want to get out of the scope of simple routing, but implementing a system for separate handling of errors *depending on the route* is quite a mess as you have to write your own route parser.\r\n\r\nSay I build a page with 2-3 different parts like public part, admin panel and api (I understand this should be independent, but please take this as an example). So we should have 3 separate 404 pages - one for the public part of the website, one for admin panel and one for an api (in xml/json format).\r\n\r\nWhat I suggest is to have at least some information returned with the error. For example, return the `handler` of the closest match, stripping parts of the original url one by one. \r\n`/admin/users/123/profile` -> `/admin/users/123` -> `/admin/users` -> `/admin`.\r\n\r\nI know this is a shitty solution, so I would like to leave this for elaboration by others, maybe some better option to handle this as with the current situtation we should route manually on error."},"comment":{"url":"https://api.github.com/repos/nikic/FastRoute/issues/comments/90533650","html_url":"https://github.com/nikic/FastRoute/issues/41#issuecomment-90533650","issue_url":"https://api.github.com/repos/nikic/FastRoute/issues/41","id":90533650,"user":{"login":"vlakarados","id":386678,"avatar_url":"https://avatars.githubusercontent.com/u/386678?v=3","gravatar_id":"","url":"https://api.github.com/users/vlakarados","html_url":"https://github.com/vlakarados","followers_url":"https://api.github.com/users/vlakarados/followers","following_url":"https://api.github.com/users/vlakarados/following{/other_user}","gists_url":"https://api.github.com/users/vlakarados/gists{/gist_id}","starred_url":"https://api.github.com/users/vlakarados/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vlakarados/subscriptions","organizations_url":"https://api.github.com/users/vlakarados/orgs","repos_url":"https://api.github.com/users/vlakarados/repos","events_url":"https://api.github.com/users/vlakarados/events{/privacy}","received_events_url":"https://api.github.com/users/vlakarados/received_events","type":"User","site_admin":false},"created_at":"2015-04-07T12:33:37Z","updated_at":"2015-04-07T12:33:37Z","body":"I see your point, I'm just interested what would be the best way to achieve this, the point is, IMO if you start to create more checks like matching prefixes, it ruins the point of FastRoute, you're kind of doing half of it's task. As I said, I would like to hear other's opinions on possible ways to achieve this without matching prefixes manually."}}