Jump to content

Check if Wire404Exception is being called


arjen
 Share

Recommended Posts

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

  • 2 months later...

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...