qw(getmaintainers_reverse),
qw(getpseudodesc),
],
- misc => [qw(make_list globify_scalar english_join checkpid)],
+ misc => [qw(make_list globify_scalar english_join checkpid),
+ qw(cleanup_eval_fail),
+ ],
date => [qw(secs_to_english)],
quit => [qw(quit)],
lock => [qw(filelock unfilelock lockpid)],
return IO::File->new('/dev/null','w');
}
+=head2 cleanup_eval_fail()
+
+ print "Something failed with: ".cleanup_eval_fail($@);
+
+Does various bits of cleanup on the failure message from an eval (or
+any other die message)
+
+Takes at most two options; the first is the actual failure message
+(usually $@ and defaults to $@), the second is the debug level
+(defaults to $DEBUG).
+
+If debug is non-zero, the code at which the failure occured is output.
+
+=cut
+
+sub cleanup_eval_fail {
+ my ($error,$debug) = @_;
+ if (not defined $error or not @_) {
+ $error = $@ || 'unknown reason';
+ }
+ if (@_ <= 1) {
+ $debug = $DEBUG || 0;
+ }
+ $debug = 0 if not defined $debug;
+
+ if ($debug > 0) {
+ return $error;
+ }
+ # ditch the "at foo/bar/baz.pm line 5"
+ $error =~ s/\sat\s\S+\sline\s\d+//;
+ # ditch trailing multiple periods in case there was a cascade of
+ # die messages.
+ $error =~ s/\.+$/\./;
+ return $error;
+}
+
1;
};
if ($@) {
$errors++;
- print {$transcript} "Failed to clear fixed versions and reopen on $ref: $@";
+ print {$transcript} "Failed to clear fixed versions and reopen on $ref: ".cleanup_eval_fail($@,$debug)."\n";
}
} elsif (m/^reopen\s+\#?(-?\d+)(?:\s+([\=\!]|(?:\S.*\S)))?$/i) {
$ok++;
};
if ($@) {
$errors++;
- print {$transcript} "Failed to reopen $ref: $@";
+ print {$transcript} "Failed to reopen $ref: ".cleanup_eval_fail($@,$debug)."\n";
}
} elsif (m{^(?:(?i)found)\s+\#?(-?\d+)
(?:\s+((?:$config{package_name_re}\/)?
};
if ($@) {
$errors++;
- print {$transcript} "Failed to add found on $ref: $@";
+ print {$transcript} "Failed to add found on $ref: ".cleanup_eval_fail($@,$debug)."\n";
}
}
else {
};
if ($@) {
$errors++;
- print {$transcript} "Failed to clear fixed versions and reopen on $ref: $@";
+ print {$transcript} "Failed to clear fixed versions and reopen on $ref: ".cleanup_eval_fail($@,$debug)."\n";
}
}
}
};
if ($@) {
$errors++;
- print {$transcript} "Failed to remove found on $ref: $@";
+ print {$transcript} "Failed to remove found on $ref: ".cleanup_eval_fail($@,$debug)."\n";
}
}
elsif (m{^(?:(?i)fixed)\s+\#?(-?\d+)
};
if ($@) {
$errors++;
- print {$transcript} "Failed to add fixed on $ref: $@";
+ print {$transcript} "Failed to add fixed on $ref: ".cleanup_eval_fail($@,$debug)."\n";
}
}
elsif (m{^(?:(?i)notfixed)\s+\#?(-?\d+)
};
if ($@) {
$errors++;
- print {$transcript} "Failed to remove fixed on $ref: $@";
+ print {$transcript} "Failed to remove fixed on $ref: ".cleanup_eval_fail($@,$debug)."\n";
}
}
elsif (m/^submitter\s+\#?(-?\d+)\s+(\!|\S.*\S)$/i) {
};
if ($@) {
$errors++;
- print {$transcript} "Failed to set submitter on $ref: $@";
+ print {$transcript} "Failed to set submitter on $ref: ".cleanup_eval_fail($@,$debug)."\n";
}
}
} elsif (m/^forwarded\s+\#?(-?\d+)\s+(\S.*\S)$/i) {
};
if ($@) {
$errors++;
- print {$transcript} "Failed to set the forwarded-to-address of $ref: $@";
+ print {$transcript} "Failed to set the forwarded-to-address of $ref: ".cleanup_eval_fail($@,$debug)."\n";
}
} elsif (m/^notforwarded\s+\#?(-?\d+)$/i) {
$ok++;
};
if ($@) {
$errors++;
- print {$transcript} "Failed to clear the forwarded-to-address of $ref: $@";
+ print {$transcript} "Failed to clear the forwarded-to-address of $ref: ".cleanup_eval_fail($@,$debug)."\n";
}
} elsif (m/^(?:severity|priority)\s+\#?(-?\d+)\s+([-0-9a-z]+)$/i) {
$ok++;
};
if ($@) {
$errors++;
- print {$transcript} "Failed to set severity of $config{bug} $ref to $newseverity: $@";
+ print {$transcript} "Failed to set severity of $config{bug} $ref to $newseverity: ".cleanup_eval_fail($@,$debug)."\n";
}
}
} elsif (m/^tags?\s+\#?(-?\d+)\s+(([=+-])\s*)?(\S.*)?$/i) {
# we intentionally have two errors here if there is a bad
# tag and the above fails for some reason
$errors++;
- print {$transcript} "Failed to alter tags of $config{bug} $ref: $@";
+ print {$transcript} "Failed to alter tags of $config{bug} $ref: ".cleanup_eval_fail($@,$debug)."\n";
}
} elsif (m/^(un)?block\s+\#?(-?\d+)\s+(?:by|with)\s+(\S.*)?$/i) {
$ok++;
};
if ($@) {
$errors++;
- print {$transcript} "Failed to set blocking bugs of $ref: $@";
+ print {$transcript} "Failed to set blocking bugs of $ref: ".cleanup_eval_fail($@,$debug)."\n";
}
} elsif (m/^retitle\s+\#?(-?\d+)\s+(\S.*\S)\s*$/i) {
$ok++;
};
if ($@) {
$errors++;
- print {$transcript} "Failed to set the title of $ref: $@";
+ print {$transcript} "Failed to set the title of $ref: ".cleanup_eval_fail($@,$debug)."\n";
}
} elsif (m/^unmerge\s+\#?(-?\d+)$/i) {
$ok++;
};
if ($@) {
$errors++;
- print {$transcript} "Failed to mark $ref as affecting package(s): $@";
+ print {$transcript} "Failed to mark $ref as affecting package(s): ".cleanup_eval_fail($@,$debug)."\n";
}
} elsif (m/^summary\s+\#?(-?\d+)\s*(\d+|)\s*$/i) {
};
if ($@) {
$errors++;
- print {$transcript} "Failed to give $ref a summary: $@";
+ print {$transcript} "Failed to give $ref a summary: ".cleanup_eval_fail($@,$debug)."\n";
}
} elsif (m/^owner\s+\#?(-?\d+)\s+((?:\S.*\S)|\!)\s*$/i) {
};
if ($@) {
$errors++;
- print {$transcript} "Failed to mark $ref as having an owner: $@";
+ print {$transcript} "Failed to mark $ref as having an owner: ".cleanup_eval_fail($@,$debug)."\n";
}
} elsif (m/^noowner\s+\#?(-?\d+)\s*$/i) {
$ok++;
};
if ($@) {
$errors++;
- print {$transcript} "Failed to mark $ref as not having an owner: $@";
+ print {$transcript} "Failed to mark $ref as not having an owner: ".cleanup_eval_fail($@,$debug)."\n";
}
} elsif (m/^unarchive\s+#?(\d+)$/i) {
$ok++;