Ivan Gretsky Posted April 11 Share Posted April 11 Good day everybody! I am trying to use wire404() in ready.php. The function throws an exception, but it is not caught with PW the standard way. The 404 page is not displayed but an error page is displayed instead. I guess that the hook to catch the exception is defined later in the request handling lifecycle. Am I right or is it something else? Can I somehow make PW catch this exception in ready.php? (in fact it doesn't work in template prepend file like _init.php either, but I need it earlier) If 2 cannot be achieved, what is a proper way to work this around and return a 404 page with 404 http code manually? Thanks in advance! P.S. The 4th of April was not so long ago so this might relate))) Link to comment Share on other sites More sharing options...
Robin S Posted April 11 Share Posted April 11 I'm not sure what the technical reason is for the 404 not being handled from ready.php, but as a workaround you could set a custom property on the $page object to indicate that a 404 should be thrown and then throw the 404 later, e.g. from a template file or from _main.php. // Your conditional in ready.php if($foo === 'bar') $page->throw404 = true; // In template file or _main.php if($page->throw404) wire404(); 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now