diff --git a/Sam/commands/edit.pm b/Sam/commands/edit.pm index 97819404077d5b5824c326121b6de043e9847547..221a80ddc406e7321b2ead1d958ca39bb30f3eb5 100644 --- a/Sam/commands/edit.pm +++ b/Sam/commands/edit.pm @@ -1,4 +1,4 @@ -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; diff --git a/Sam/commands/parser.pm b/Sam/commands/parser.pm index a28df21e8494add40b85f09b1b2984622bd66248..3824e49cb7d73bf623287d3006512fbef1f4f0a5 100644 --- a/Sam/commands/parser.pm +++ b/Sam/commands/parser.pm @@ -84,7 +84,16 @@ sub exec { my $command = $2; my $arg = $3; - Sam::commands::edit::exec($id, $command, $arg, $chan); + 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);