Errors generate warnings

html/Element/Errors generates uninitialized value warnings if the parameter
$Details is not passed in, and if the SessionType is undefined. The following
patch quietens it.

Nicholas Clark

Index: html/Elements/Error
RCS file: /export/cvsroot/rt-external/html/Elements/Error,v
retrieving revision 1.1.1.1
diff -p -u -r1.1.1.1 Error
— html/Elements/Error 21 May 2007 14:38:40 -0000 1.1.1.1
+++ html/Elements/Error 15 Jun 2007 16:17:14 -0000
@@ -49,7 +49,7 @@

<%$Why%>
-<%$Details%> +<% defined $Details ? $Details : '' %>

<%cleanup>
@@ -65,7 +65,8 @@ $Why => loc("the calling component did n
</%args>

<%INIT>
-my $error = “WebRT: $Why ($Details)”;
+my $error = "WebRT: $Why “;
+$error .= " ($Details)” if defined $Details;

TODO: Log::Dispatch isn’t UTF-8 safe. Autrijus needs to talk to dave rolsky about getting this fixed

if ($] >= 5.007001) {
@@ -75,10 +76,10 @@ if ($] >= 5.007001) {

$RT::Logger->error($error);

-if ( $session{‘SessionType’} eq ‘REST’ ) {
+if ( defined $session{‘SessionType’} && $session{‘SessionType’} eq ‘REST’ ) {
$r->content_type(‘text/plain’);
$m->out( "Error: " . $Why . “\n” );

  • $m->out( $Details . “\n” );
  • $m->out( $Details . “\n” ) if defined $Details;
    $m->abort();
    }
    </%INIT>

About to apply this equivalent, slightly more Masonic patch. Thanks!

=== html/Elements/Error
— html/Elements/Error (revision 58163)
+++ html/Elements/Error (local)
@@ -61,7 +61,7 @@

<%args>
$Code => undef
-$Details => undef
+$Details =>‘’
$Title => loc(“RT Error”)
$Why => loc(“the calling component did not specify why”)
</%args>
@@ -77,7 +77,7 @@

$RT::Logger->error($error);

-if ( $session{‘SessionType’} eq ‘REST’ ) {
+if ( defined ($session{‘SessionType’} && $session{‘SessionType’} eq
‘REST’ ) {
$r->content_type(‘text/plain’);
$m->out( "Error: " . $Why . “\n” );
$m->out( $Details . “\n” );On Jun 15, 2007, at 12:23 PM, Nicholas Clark wrote:

html/Element/Errors generates uninitialized value warnings if the
parameter
$Details is not passed in, and if the SessionType is undefined. The
following
patch quietens it.

Nicholas Clark

Index: html/Elements/Error

RCS file: /export/cvsroot/rt-external/html/Elements/Error,v
retrieving revision 1.1.1.1
diff -p -u -r1.1.1.1 Error
— html/Elements/Error 21 May 2007 14:38:40 -0000 1.1.1.1
+++ html/Elements/Error 15 Jun 2007 16:17:14 -0000
@@ -49,7 +49,7 @@

<%$Why%>
-<%$Details%> +<% defined $Details ? $Details : '' %>

<%cleanup>
@@ -65,7 +65,8 @@ $Why => loc("the calling component did n
</%args>

<%INIT>
-my $error = “WebRT: $Why ($Details)”;
+my $error = "WebRT: $Why “;
+$error .= " ($Details)” if defined $Details;

TODO: Log::Dispatch isn’t UTF-8 safe. Autrijus needs to talk to

dave rolsky about getting this fixed
if ($] >= 5.007001) {
@@ -75,10 +76,10 @@ if ($] >= 5.007001) {

$RT::Logger->error($error);

-if ( $session{‘SessionType’} eq ‘REST’ ) {
+if ( defined $session{‘SessionType’} && $session{‘SessionType’} eq
‘REST’ ) {
$r->content_type(‘text/plain’);
$m->out( "Error: " . $Why . “\n” );

  • $m->out( $Details . “\n” );
  • $m->out( $Details . “\n” ) if defined $Details;
    $m->abort();
    }
    </%INIT>

List info: lists.bestpractical.com Mailing Lists
rt-devel

PGP.sig (186 Bytes)

About to apply this equivalent, slightly more Masonic patch. Thanks!

=== html/Elements/Error

— html/Elements/Error (revision 58163)
+++ html/Elements/Error (local)
@@ -61,7 +61,7 @@

<%args>
$Code => undef
-$Details => undef
+$Details =>’’
$Title => loc(“RT Error”)
$Why => loc(“the calling component did not specify why”)
</%args>

I thought about that, but I wasn’t sure whether $Details being undef was
intended to be a significant difference from $Details being an empty string.
Thinking about it now, it would seem pretty silly to have an empty string as
the supplied text detailing the error. So, yes, that approach is better.

Nicholas Clark