in reply to Perl Style: About error messges opening files
I agree with Abigail that it definitely matters who's going to see this message. If it's going to show up in an error log, I just make sure it's a unique string that I can grep for easily, something like this:
foo or die "sorrow, pestilence, Notepad: $!$/";As long as I don't use the same error string twice, it takes about two seconds to find the place where the problem is.
If it's an error message that an end user is going to see, I do something rather different...
open FOO, "<$foo" or fatalerror "Couldn't Read Foo: $!"; # and off in an include file somewhere I define... sub fatalerror { my $email = $ENV{SERVER_ADMIN}; use HTML::Entities; my $code = encode_entities(shift); my $fm = <<"FRIENDLYMESSAGE"; <p class=\"error\">Oops! I seem to have run into a problem! This is probably a bug in the software on this site, something that the webmaster needs to fix. If this problem persists, you can contact the webmaster at <a href="mailto:$email">$email</a> and report the problem. It might get fixed faster if you include the exact technical error code that follows. </p> <p class=\"error\">Technical Error Code: $code</p> FRIENDLYMESSAGE # And then I output a page containing $fm in the # usual fashion. }
This is for CGI, which in my case is the only kind of interface used for stuff that end users see, but you can imagine a similar sort of thing for GUI stuff.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Perl Style: About error messges opening files
by demerphq (Chancellor) on Apr 27, 2004 at 21:12 UTC | |
|
Re: Re: Perl Style: About error messges opening files
by Juerd (Abbot) on Apr 28, 2004 at 10:07 UTC | |
by Anonymous Monk on Apr 28, 2004 at 18:59 UTC | |
by jonadab (Parson) on Apr 30, 2004 at 20:12 UTC | |
by Juerd (Abbot) on Apr 30, 2004 at 22:42 UTC | |
by jonadab (Parson) on May 04, 2004 at 14:31 UTC | |
by Juerd (Abbot) on May 04, 2004 at 17:28 UTC | |
|