How do I personalize my error messages?
I changed the standard_error_message file but whenever I recieve an error my changes are not reflected. I have tried restarting the server and this did not help. Any help would be greatly appreciated. Thanks
Bizarre as it seems, not all error messages go to standard_error_message. Some obvious ones such as 404 for example. Add yourself to the growing list of people who think this is annoying. -- Andy McKay. ----- Original Message ----- From: "Smith, RyanX" <ryanx.smith@intel.com> To: <zope@zope.org> Sent: Friday, February 23, 2001 5:32 PM Subject: [Zope] How do I personalize my error messages?
I changed the standard_error_message file but whenever I recieve an error my changes are not reflected. I have tried restarting the server and this did not help. Any help would be greatly appreciated.
Thanks
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
On 23 Feb, Andy McKay wrote:
Bizarre as it seems, not all error messages go to standard_error_message. Some obvious ones such as 404 for example. Add yourself to the growing list of people who think this is annoying.
The problem is not as simple as it may seem. Zope tries the request thru it's traversal machinery, but what if there isn't anything to traverse ? It would have to go back and try bottom up for a standard_error_message, keeping the last one found until it fails to find one. The way that problem is solved right now is by hardcoding the message you end up seeing into the zope code. I used to have a patch around which would instead hardcode the standard_error_message found in / to make it at least configurable, I lost that patch in a recent HD crash. Someone on IRC tested it out and found it better then the current solution, perhaps he's listening ?? It's in HTTPResponse.py, and it was rather trivial. -Th
404 error messages do go to the standard_error_message. an example of those that do not would be the failed authentication. i have a custom standard_error on all of my sites and it works beautifully. there used to be problems with versions of Zope earlier than 2.2.4 i believe where customizing wouldn't do much. and by the way, you will get the hardcoded error message if your standard_error_message itself throws an error. see my own standard error message below. it checks for "NotFound" error types (->404), tries to redirect correctly in case the error came from a stale bookmark, and as a last resort it prints a message. then it sends mail to me so i know what failed. all other errors get a more generic error message and i get mail sent to me as well. **************************** <dtml-var name="standard_html_header"> <dtml-if expr="error_type == 'NotFound'"> <h1>Error 404: Cannot find requested page</h1> <p><br></p> <dtml-if expr="_.string.replace(URL0, SERVER_URL, '') =='/numbers_html' or _.string.replace(URL0, SERVER_URL, '')=='/technology_html'"> <dtml-call expr="RESPONSE.redirect('/technology', status=301, lock=1)"> <dtml-elif expr="_.string.replace(URL0, SERVER_URL, '')=='/links_html'"> <dtml-call expr="RESPONSE.redirect('/sites/links_html' , status=301, lock=1)"> <dtml-elif expr="_.string.replace(URL0, SERVER_URL, '')=='/history_html'"> <dtml-call expr="RESPONSE.redirect('/history', status=301, lock=1)"> <dtml-elif expr="_.string.replace(URL0, SERVER_URL, '')=='/problems_html'"> <dtml-call expr="RESPONSE.redirect('/technology/problems_html', status=301, lock=1)"> <dtml-elif expr="_.string.find(PATH_INFO, 'spares_html') != -1"> <dtml-call expr="RESPONSE.redirect('/spares', status=301, lock=1)"> <dtml-elif expr="_.string.replace(URL0, SERVER_URL, '')=='/pictures/accessories_html'"> <dtml-call expr="RESPONSE.redirect('/pictures/accessories', status=301, lock=1)"> <dtml-elif expr="_.string.find(PATH_INFO, '/pictures/images') != -1 or _.string.replace(URL0, SERVER_URL, '')=='/pictures/pix_html'"> <dtml-call expr="RESPONSE.redirect('/pictures', status=301, lock=1)"> <dtml-else> <p>The page you were looking for: </p> <p> <dtml-var name="URL0"></p> <p>has been moved or removed. The navigation menu to the left has available choices.</p> <dtml-sendmail smtphost="xyz.mymail.com"> To: broken_links@mymail.com From: Broken Link <webmaster@mymail.com> Subject: [Error] Oops 404 Reported a 404 for the following URL: <dtml-var name="URL0"> <dtml-if name="REMOTE_HOST"> Requested by Host: <dtml-var name="REMOTE_HOST"> </dtml-if> <dtml-if name="REMOTE_ADDR"> Requested by Address: <dtml-var name="REMOTE_ADDR"> </dtml-if> <dtml-if name="HTTP_REFERER"> Linked from: <dtml-var name="HTTP_REFERER"> </dtml-if> </dtml-sendmail> </dtml-if> <p><br></p> <p>Please adjust your bookmarks!</p> <dtml-else> <h1>A horrible error occurred!</h1> <p><br></p> <p>A report has been sent to the webmaster.</p> <dtml-sendmail smtphost="xyz.mymail.com"> To: site_errors@mymail.com From: Site Errors <webmaster@mymail.com> Subject: [Error] <dtml-if name="error_type"><dtml-var name="error_type"><dtml-else>Oops</dtml-if> Reported an error <dtml-if name="error_type">of type <dtml-var name="error_type"> </dtml-if>for the following URL: <dtml-var name="URL0"> <dtml-if name="REMOTE_HOST"> Requested by Host: <dtml-var name="REMOTE_HOST"> </dtml-if> <dtml-if name="REMOTE_ADDR"> Requested by Address: <dtml-var name="REMOTE_ADDR"> </dtml-if> <dtml-if name="HTTP_REFERER"> Linked from: <dtml-var name="HTTP_REFERER"> </dtml-if> <dtml-if name="error_tb"> <dtml-var name="error_tb"> </dtml-if> </dtml-sendmail> </dtml-if> <dtml-var name="standard_html_footer"> ************** hth jens on 2/23/01 20:40, Andy McKay at andym@ActiveState.com wrote:
Bizarre as it seems, not all error messages go to standard_error_message. Some obvious ones such as 404 for example. Add yourself to the growing list of people who think this is annoying. -- Andy McKay.
----- Original Message ----- From: "Smith, RyanX" <ryanx.smith@intel.com> To: <zope@zope.org> Sent: Friday, February 23, 2001 5:32 PM Subject: [Zope] How do I personalize my error messages?
I changed the standard_error_message file but whenever I recieve an error my changes are not reflected. I have tried restarting the server and this did not help. Any help would be greatly appreciated.
Thanks
Andy McKay wrote:
Bizarre as it seems, not all error messages go to standard_error_message. Some obvious ones such as 404 for example.
Huh?! Our standard_error_message's catch 404s They don't catch Auth errors though, which is something that neesd fixing. What also neesd fixing is the way the traceback is plonked on the end of any generated HTML (yes, after the </HTML>), generating badly formed HTML and giving out information about your site you may not want to. Both of these I'd love to fix, and may well do if I can just squeeze 26 hours into a day ;-) cheers, Chris
Sorry 404 does, Authentication doesnt. -- Andy McKay. ----- Original Message ----- From: "Andy McKay" <andym@ActiveState.com> To: "Smith, RyanX" <ryanx.smith@intel.com>; <zope@zope.org> Sent: Friday, February 23, 2001 5:40 PM Subject: Re: [Zope] How do I personalize my error messages?
Bizarre as it seems, not all error messages go to standard_error_message. Some obvious ones such as 404 for example. Add yourself to the growing list of people who think this is annoying. -- Andy McKay.
----- Original Message ----- From: "Smith, RyanX" <ryanx.smith@intel.com> To: <zope@zope.org> Sent: Friday, February 23, 2001 5:32 PM Subject: [Zope] How do I personalize my error messages?
I changed the standard_error_message file but whenever I recieve an error my changes are not reflected. I have tried restarting the server and this did not help. Any help would be greatly appreciated.
Thanks
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (5)
-
Andy McKay -
Chris Withers -
Jens Vagelpohl -
Smith, RyanX -
thomas@hentschel.net