Ignore:
Timestamp:
01/22/12 15:24:36 (4 months ago)
Author:
GeorgeClark
Message:

Item11462: Improve Net.pm error message handling

When run under configure, there is no Session. Calls to logger fail
masking other errors. Only call logger when there is a session.

Make sure every error is sent to STDERR.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Release01x01/core/lib/Foswiki/Net.pm

    r12574 r13779  
    302302        eval "require $this->{MAIL_METHOD};"; 
    303303        if ($@) { 
    304             print STDERR "FAILED $@ \n"; 
     304            print STDERR ">>>> Failed to load $this->{MAIL_METHOD}: $@ \n"; 
    305305            $this->{session}->logger->log( 'warning', 
    306306                "$this->{MAIL_METHOD} not available: $@" ) 
     
    385385            my $e = shift->stringify(); 
    386386            ( my $to ) = $text =~ /^To:\s*(.*?)$/im; 
    387             $this->{session}->logger->log( 'warning', "Emailing $to - $e" ) 
     387            $this->{session} 
     388              ->logger->log( 'warning', "Error sending email $to - $e" ) 
    388389              if ( $this->{session} ); 
     390            print STDERR ">>>> FAILURE Sending e-mail to $to - $e\n"; 
    389391 
    390392            # be nasty to errors that we didn't throw. They may be 
     
    454456        }; 
    455457        if ($@) { 
    456             print STDERR "Crypt::SMIME Failed: $@ \n"; 
     458            print STDERR ">>>> Crypt::SMIME Failed: $@ \n"; 
    457459            $this->{session}->logger->log( 'warning', "S/MIME FAILED: $@" ) 
    458460              if ( $this->{session} ); 
     
    598600    die $mess . "Can't connect to '$this->{MAIL_HOST}'" unless $smtp; 
    599601 
    600 #print STDERR ">>>>>>>>>>>>> ABOUT TO AUTH with $Foswiki::cfg{SMTP}{Username} \n"; 
     602    print STDERR 
     603">>>> SMTP auth: Attempting authentication for $Foswiki::cfg{SMTP}{Username} \n" 
     604      if ( $Foswiki::cfg{SMTP}{Debug} && $Foswiki::cfg{SMTP}{Username} ); 
    601605 
    602606    if ( $Foswiki::cfg{SMTP}{Username} 
    603607        && !( $this->{MAIL_METHOD} eq 'Net::SMTP::TLS' ) ) 
    604608    { 
     609        unless ( $Foswiki::cfg{SMTP}{Password} ) { 
     610            my $errmsg = 
     611"SMTP auth: AUTH requested for $Foswiki::cfg{SMTP}{Username} but no password provided"; 
     612            print STDERR ">>>> $errmsg \n" if $Foswiki::cfg{SMTP}{Debug}; 
     613            $this->{session}->logger->log( 'warning', "$errmsg" ) 
     614              if $this->{session}; 
     615        } 
    605616 
    606617        unless ( 
     
    615626            chomp($errmsg); 
    616627            $errmsg .= ' - Trying to send without authentication'; 
    617             $this->{session}->logger->log( 'warning', "$errmsg" ); 
     628            $this->{session}->logger->log( 'warning', "$errmsg" ) 
     629              if $this->{session}; 
     630            print STDERR ">>>> FAILURE - $errmsg\n"; 
    618631        } 
    619632    } 
Note: See TracChangeset for help on using the changeset viewer.