Yes, in part what I'm saying is I need to do more advanced error handling.
croak and die don't give the calling line number.
Page security is already taken care of. The script in question accepts a
student ID (told by the student to an office worker) and prints a contract
on the office printer for that person, and then goes back to the input
screen automatically. So 99.99% of errors are either the student telling
them the ID incorrectly, or the staff keying the ID incorrectly.
The idea of emailing myself the error (other than a mis-keyed ID) is
appealing. And would allow me to just "die;" rather than "confess;" I can
take care of adding that, thanks for the suggestion. Actually, this is the
answer to not confusing the end user. :-)
If you want more gory details on the existing error routine:
Here is an example error call:
PrintError ("Parameter is not numeric.", , 1, \$HeadOpen) if ($Parameter !~
m/^(\d{1,8})$/);
Most commonly called error call:
($InternalID) = $sth->fetchrow_array() or
PrintError ('ID not found. Please check the ID and try again.',
$sth->errstr, 1, \$HeadOpen);
There are currently 18 calls to PrintError in this relatively simple
program.
Here is the subroutine I've got now:
sub PrintError {
my ($Message, $Message2, $Die, $HeadOpenRef) = @_;
if (${$HeadOpenRef}) {
print '<meta http-equiv="REFRESH" content="20; URL=', $returnadr,
'"></head><body>';
${$HeadOpenRef} = 0;
HSNGSANDDB->headclose();
}
print ('<h1>', $Message, '</h1><br>');
if ($Message2) {
print ($Message2, '<br>');
}
if ($Die) {
confess ();
}
}
ID not found. Please check the ID and try again.
Software error:
at <path>\PrintAContract.pl line 453
main::PrintError('ID not found. Please check the ID and try again.',
undef, 1, 'SCALAR(0x240d6dc)') called at <path>\PrintAContract.pl line
109
For help, please send mail to this site's webmaster, giving this error
message and the time and date of the error.
[Fri Mar 14 19:39:08 2014] PrintAContract.pl: at <path>\PrintAContract.pl
line 453 [Fri Mar 14 19:39:08 2014] PrintAContract.pl: main::PrintError('ID
not found. Please check the ID and try again.', undef, 1,
'SCALAR(0x240d6dc)') called at <path>\PrintAContract.pl line 109
On Fri, Mar 14, 2014 at 10:48 AM, Csaba Toth <[email protected]>wrote:
> It wasn't clear to me if you want to display call stack and detailed error
> information or not. Usually you don't want detailed information for a user,
> just a simple error message to avoid confusion and to not help certain hack
> attempts (an attacker gain information on the internals of your app). In
> production you can get the detailed message from the logs. During debug and
> development you want detailed info. But it sounded like Paul wants the
> detailed info.
>
>
> On Fri, Mar 14, 2014 at 6:24 AM, Brian J. Miller <[email protected]>wrote:
>
>> Is the "lot of extra stuff" the stack trace? If it is, then don't use
>> `confess` use `croak` or `die`. `confess` is giving you a stack trace.
>>
>>
--
--
You received this message because you are subscribed to the Google Groups
"NLUG" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nlug-talk?hl=en
---
You received this message because you are subscribed to the Google Groups
"NLUG" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.