Skip to content
Extraits de code Groupes Projets
Valider dd708296 rédigé par Alexandre Morignot's avatar Alexandre Morignot
Parcourir les fichiers

Sam::commands::edit errors handling

parent 90e31d09
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
package Sam::Sam::commands::edit;
package Sam::commands::edit;
require Exporter;
our @ISA = qw(Exporter);
......@@ -20,7 +20,7 @@ sub exec {
if ($command eq "lien" or $command eq "url" or $command eq "link") {
if ($arg !~ /^$RE{URI}{HTTP}{-scheme => qr(https?)}$/) {
$irc->yield(privmsg => $chan => "Ce n'est pas une url valide");
die "Ce n'est pas une URL valide";
}
else {
eval {
......@@ -28,25 +28,22 @@ sub exec {
$sth->execute($arg, $id);
if ($sth->rows == 0) {
$irc->yield(privmsg => $chan => "Aucune soirée trouvée avec cet identifiant");
}
else {
$irc->yield(privmsg => $chan => "Oui chef !");
die "Aucune soirée trouvée avec cet identifiant";
}
$dbh->commit;
};
if ($@) {
$log->error("Quelque chose a chié dans la transaction : $@");
$log->error("$@");
$dbh->rollback;
$irc->yield(privmsg => $chan => "Erreur, commande non exécutée");
die $@;
}
}
}
else {
$irc->yield(privmsg => $chan => "Commande inconnue");
die "Commande inconnue";
}
$dbh->{AutoCommit} = $saveCommit;
......
......@@ -84,7 +84,16 @@ sub exec {
my $command = $2;
my $arg = $3;
eval {
Sam::commands::edit::exec($id, $command, $arg, $chan);
};
if ($@) {
$irc->yield(privmsg => $chan => "Erreur : $@");
}
else {
$irc->yield(privmsg => $chan => "Oui chef !");
}
}
elsif ($msg =~ /^Sam(?:,|:) +j'y +vais/) {
Sam::commands::addUser::exec($nick, $lastID->{$chan->[0]}, $chan);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter