arjen Posted January 14, 2013 Share Posted January 14, 2013 I want to make a little module which logs all 404's and some more info like IP address, time, referrer, et cetera. Also it would be a nice addition if a developer generated 404 (i.e. using urlSegments and Throw Wire404Exception) could be included too. I think I can handle most stuff, but do have two questions: 1) How can I check if a Wire404Exception is being called? 2) When catching a Wire404Exception does that include all (both system and developer) generated 404's? Thanks! Link to comment Share on other sites More sharing options...
WillyC Posted January 14, 2013 Share Posted January 14, 2013 why.not just make custom tamplate for 404 page? 3 Link to comment Share on other sites More sharing options...
Pete Posted January 14, 2013 Share Posted January 14, 2013 Yup - the 404 page is in the site tree as Willy says, so you could just change set a template for that page and do some code in there to keep it simple Link to comment Share on other sites More sharing options...
Soma Posted January 14, 2013 Share Posted January 14, 2013 Yeah keep it simple Link to comment Share on other sites More sharing options...
arjen Posted January 14, 2013 Author Share Posted January 14, 2013 Simple is good. I've thought about using the default 404 template, but a module seemed more logical. I use the 404 for markup purposes. Perhaps I have to rethink this. Link to comment Share on other sites More sharing options...
isellsoap Posted April 13, 2013 Share Posted April 13, 2013 So there really isn’t a way to check if Wire404Exception is being called? I have the problem that when throw new Wire404Exception(); is being called, then the code of the 404 template is being included on the same page, but when another 404 occurs (e.g. the user typed a $input->urlSegment2 in the address bar, although only one segment is allowed) then only the 404 template is being called (that is without the inclusion of head.inc and foot.inc). Do you guys see what I mean? So I’d need a method to check if Wire404Exception is explicitly called, so I know when and when not to include head.inc and foot.inc in the 404 template. Link to comment Share on other sites More sharing options...
isellsoap Posted April 13, 2013 Share Posted April 13, 2013 Solved it. I just throw the exception at the top of the page, before the head.inc of that page is included. Now I can call head.inc in the 404 template without worrying. 1 Link to comment Share on other sites More sharing options...
ryan Posted April 13, 2013 Share Posted April 13, 2013 You got it–a 404 should be thrown before you start outputting a page. If there is some other fatal error that occurs after you've started rendering your markup, it's better to throw a more generic WireException('your error message'). 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