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; require Exporter;
our @ISA = qw(Exporter); our @ISA = qw(Exporter);
...@@ -20,7 +20,7 @@ sub exec { ...@@ -20,7 +20,7 @@ sub exec {
if ($command eq "lien" or $command eq "url" or $command eq "link") { if ($command eq "lien" or $command eq "url" or $command eq "link") {
if ($arg !~ /^$RE{URI}{HTTP}{-scheme => qr(https?)}$/) { 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 { else {
eval { eval {
...@@ -28,25 +28,22 @@ sub exec { ...@@ -28,25 +28,22 @@ sub exec {
$sth->execute($arg, $id); $sth->execute($arg, $id);
if ($sth->rows == 0) { if ($sth->rows == 0) {
$irc->yield(privmsg => $chan => "Aucune soirée trouvée avec cet identifiant"); die "Aucune soirée trouvée avec cet identifiant";
}
else {
$irc->yield(privmsg => $chan => "Oui chef !");
} }
$dbh->commit; $dbh->commit;
}; };
if ($@) { if ($@) {
$log->error("Quelque chose a chié dans la transaction : $@"); $log->error("$@");
$dbh->rollback; $dbh->rollback;
$irc->yield(privmsg => $chan => "Erreur, commande non exécutée"); die $@;
} }
} }
} }
else { else {
$irc->yield(privmsg => $chan => "Commande inconnue"); die "Commande inconnue";
} }
$dbh->{AutoCommit} = $saveCommit; $dbh->{AutoCommit} = $saveCommit;
......
...@@ -84,7 +84,16 @@ sub exec { ...@@ -84,7 +84,16 @@ sub exec {
my $command = $2; my $command = $2;
my $arg = $3; my $arg = $3;
eval {
Sam::commands::edit::exec($id, $command, $arg, $chan); 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/) { elsif ($msg =~ /^Sam(?:,|:) +j'y +vais/) {
Sam::commands::addUser::exec($nick, $lastID->{$chan->[0]}, $chan); 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