Skip to content

Commit 50f7d2a

Browse files
committed
Try catching BZ failures
1 parent ed2a848 commit 50f7d2a

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

script/git-to-bugzilla.pl

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use FindBin;
1111
use Getopt::Long;
1212
use Git::Repository;
13+
use Try::Tiny;
1314

1415
use lib "$FindBin::Bin/../lib";
1516
use WWW::Bugzilla;
@@ -23,13 +24,24 @@ sub update_bugzilla {
2324
my $info = shift;
2425
my $set = shift;
2526

26-
my $bz = WWW::Bugzilla->new(
27-
server => $cfg->{bugzilla}{server},
28-
email => $cfg->{bugzilla}{user},
29-
password => $cfg->{bugzilla}{pass},
30-
use_ssl=>1,
31-
bug_number => $set->{bug}
32-
) || croak "Cannot open bz - $!";
27+
my $bz;
28+
my $fail;
29+
try {
30+
$bz = WWW::Bugzilla->new(
31+
server => $cfg->{bugzilla}{server},
32+
email => $cfg->{bugzilla}{user},
33+
password => $cfg->{bugzilla}{pass},
34+
use_ssl => 1,
35+
bug_number => $set->{bug}
36+
);
37+
} catch {
38+
if (/Bug #\d+ does not exist/) {
39+
warn sprintf("Bug #%s does not exist\n", $set->{bug});
40+
}
41+
$fail = 1;
42+
};
43+
return if ($fail);
44+
croak "Cannot open bz - $!" unless($bz);
3345

3446
my $header =
3547
sprintf( "Git commit: %s/commitdiff/%s\n", $cfg->{gitweb}, $info->{rev} );

0 commit comments

Comments
 (0)