I would like to throw a 404 when a user tries to access something that 
doesn't exist, like trying to access a non-existent comment by providing a 
comment id that doesn't exist in the database. In these cases, web2py will 
throw an exception and point to a ticket (ie, NoneType has no attribute 
'id' or something).

Instead, I'd like to throw up a custom 404 page which I have created. This 
seems possible with routes_onerror (taken from the docs):

 ('*/404', '/init/static/cantfind.html')



However, my understanding from other threads is that this would not preserve 
the error code. I found a nice example that
points routes_onerror to a custom error handler, which will then preserve the 
error code:
http://www.web2pyslices.com/slice/show/1529/custom-error-routing

In that code slice, it just returns a string like "Not found" for the errors. 
How would I have web2py redirect
to my custom_404.html instead?

Then, in my controller, would I still do something like:

if not comment:    
    raise HTTP(404, 'sorry, that post does not exist')

Even though the message 'sorry, that post does not exist' doesn't matter 
anymore? I would be displaying my custom_404.html instead of this message?


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to