Changeset ebfcc87


Ignore:
Timestamp:
May 19, 2010, 12:29:51 PM (14 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.10, release-1.7, release-1.8, release-1.9
Children:
8278543
Parents:
bacf674
git-author:
Nelson Elhage <nelhage@mit.edu> (05/19/10 12:28:23)
git-committer:
Nelson Elhage <nelhage@mit.edu> (05/19/10 12:29:51)
Message:
Jabber: Consistently use die() with a trailine newline.

We had a number of places where we would call BarnOwl::error(), but
not bail out, even though the error should have been fatal. Also, we
should never call die() for user-facing errors without a trailing
newline, which suppresses the file/line display.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    rbacf674 rebfcc87  
    377377        my $cjidStr = $conn->baseJIDExists($jidStr);
    378378        if ($cjidStr) {
    379             BarnOwl::error("Already logged in as $cjidStr.");
    380             return;
     379            die("Already logged in as $cjidStr.\n");
    381380        }
    382381    }
     
    387386
    388387    if ( !$uid || !$componentname ) {
    389         BarnOwl::error("usage: $cmd JID");
    390         return;
     388        die("usage: $cmd JID\n");
    391389    }
    392390
    393391    if ( $conn->jidActive($jidStr) ) {
    394         BarnOwl::error("Already logged in as $jidStr.");
    395         return;
     392        die("Already logged in as $jidStr.\n");
    396393    } elsif ($conn->jidExists($jidStr)) {
    397394        return $conn->tryReconnect($jidStr, 1);
     
    526523sub cmd_jlist {
    527524    if ( !( scalar $conn->getJIDs() ) ) {
    528         BarnOwl::error("You are not logged in to Jabber.");
    529         return;
     525        die("You are not logged in to Jabber.\n");
    530526    }
    531527    BarnOwl::popless_ztext( onGetBuddyList() );
     
    534530sub cmd_jwrite {
    535531    if ( !$conn->connected() ) {
    536         BarnOwl::error("You are not logged in to Jabber.");
    537         return;
     532        die("You are not logged in to Jabber.\n");
    538533    }
    539534
     
    559554
    560555    if ( scalar @ARGV != 1 ) {
    561         BarnOwl::error(
    562             "Usage: jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>]");
    563         return;
     556        die("Usage: jwrite <jid> [-t <thread>] [-s <subject>] [-a <account>]\n");
    564557    }
    565558    else {
     
    570563
    571564    unless(scalar @candidates) {
    572         die("Unable to resolve JID $to");
     565        die("Unable to resolve JID $to\n");
    573566    }
    574567
     
    577570    unless(scalar @candidates) {
    578571        if(!$from) {
    579             die("You must specify an account with -a");
     572            die("You must specify an account with -a\n");
    580573        } else {
    581             die("Unable to resolve account $from");
     574            die("Unable to resolve account $from\n");
    582575        }
    583576    }
     
    631624    my $func = $jmuc_commands{$cmd};
    632625    if ( !$func ) {
    633         BarnOwl::error("jmuc: Unknown command: $cmd");
    634         return;
     626        die("jmuc: Unknown command: $cmd\n");
    635627    }
    636628
     
    654646        }
    655647        else {
    656             BarnOwl::error('You must specify an account with -a <jid>');
     648            die("You must specify an account with -a <jid>\n");
    657649        }
    658650        return $func->( $jid, $muc, @ARGV );
     
    667659
    668660    $muc = shift @ARGV
    669       or die("Usage: jmuc join <muc> [-p <password>] [-a <account>]");
     661      or die("Usage: jmuc join <muc> [-p <password>] [-a <account>]\n");
    670662
    671663    die("Error: Must specify a fully-qualified MUC name (e.g. barnowl\@conference.mit.edu)\n")
     
    688680
    689681    $muc = shift @args if scalar @args;
    690     die("Usage: jmuc part [<muc>] [-a <account>]") unless $muc;
     682    die("Usage: jmuc part [<muc>] [-a <account>]\n") unless $muc;
    691683
    692684    if($conn->getConnectionFromJID($jid)->MUCLeave(JID => $muc)) {
    693685        queue_admin_msg("$jid has left $muc.");
    694686    } else {
    695         die("Error: Not joined to $muc");
     687        die("Error: Not joined to $muc\n");
    696688    }
    697689}
     
    703695    $muc = shift @args if scalar @args;
    704696
    705     die('Usage: jmuc invite <jid> [<muc>] [-a <account>]')
     697    die("Usage: jmuc invite <jid> [<muc>] [-a <account>]\n")
    706698      unless $muc && $invite_jid;
    707699
     
    718710    my ( $jid, $muc, @args ) = @_;
    719711    $muc = shift @args if scalar @args;
    720     die("Usage: jmuc configure [<muc>]") unless $muc;
     712    die("Usage: jmuc configure [<muc>]\n") unless $muc;
    721713    my $iq = Net::Jabber::IQ->new();
    722714    $iq->SetTo($muc);
     
    759751
    760752    $muc = shift @args if scalar @args;
    761     die("Usage: jmuc presence [<muc>]") unless $muc;
     753    die("Usage: jmuc presence [<muc>]\n") unless $muc;
    762754
    763755    if ($muc eq '-a') {
     
    774766    else {
    775767        my $m = $conn->getConnectionFromJID($jid)->FindMUC(jid => $muc);
    776         die("No such muc: $muc") unless $m;
     768        die("No such muc: $muc\n") unless $m;
    777769        BarnOwl::popless_ztext(jmuc_presence_single($m));
    778770    }
     
    801793    my $func = $jroster_commands{$cmd};
    802794    if ( !$func ) {
    803         BarnOwl::error("jroster: Unknown command: $cmd");
    804         return;
     795        die("jroster: Unknown command: $cmd\n");
    805796    }
    806797
     
    825816        }
    826817        else {
    827             BarnOwl::error('You must specify an account with -a <jid>');
     818            die("You must specify an account with -a <jid>\n");
    828819        }
    829820        return $func->( $jid, $name, \@groups, $purgeGroups,  @ARGV );
     
    849840    }
    850841    else {
    851         BarnOwl::error('You must specify an account with -a <jid>');
     842        die("You must specify an account with -a <jid>\n");
    852843    }
    853844
     
    13311322        return $givenJIDStr if ($conn->jidExists($givenJIDStr) );
    13321323        return resolveConnectedJID($givenJID->GetJID('base')) if $loose;
    1333         die("Invalid account: $givenJIDStr");
     1324        die("Invalid account: $givenJIDStr\n");
    13341325    }
    13351326
     
    13841375        # Not one of ours.
    13851376        else {
    1386             die("Invalid account: $givenJIDStr");
     1377            die("Invalid account: $givenJIDStr\n");
    13871378        }
    13881379
     
    14301421    if($from) {
    14311422        $from_jid = resolveConnectedJID($from, 1);
    1432         die("Unable to resolve account $from") unless $from_jid;
     1423        die("Unable to resolve account $from\n") unless $from_jid;
    14331424        $to_jid = resolveDestJID($to, $from_jid);
    14341425        push @matches, [$from_jid, $to_jid] if $to_jid;
Note: See TracChangeset for help on using the changeset viewer.