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

handle some errors on insert

And this is probably just the begining… but this is the goal of
RaisErrors.
parent 9186c86a
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -17,12 +17,15 @@ sub addTag ...@@ -17,12 +17,15 @@ sub addTag
my $sth; my $sth;
$sth = $dbh->prepare_cached('INSERT INTO playbot_tags (id, tag) $sth = $dbh->prepare_cached('INSERT INTO playbot_tags (id, tag) VALUES (?, ?)');
VALUES (?, ?)');
$log->error("Couldn't prepare querie; aborting") unless (defined $sth); $log->error("Couldn't prepare querie; aborting") unless (defined $sth);
eval {
$sth->execute($id, $tag) $sth->execute($id, $tag)
or $log->error("Couldn't finish transaction: " . $dbh->errstr); };
if ($@) {
$log->error("Couldn't finish transaction: " . $@);
}
} }
1; 1;
...@@ -65,14 +65,20 @@ sub parse { ...@@ -65,14 +65,20 @@ sub parse {
} }
else { else {
# insertion de la vidéo dans la bdd # insertion de la vidéo dans la bdd
eval {
my $sth = $dbh->prepare_cached(' my $sth = $dbh->prepare_cached('
INSERT INTO playbot (type, url, sender, title, duration) INSERT INTO playbot (type, url, sender, title, duration)
VALUES (?,?,?,?,?)'); VALUES (?,?,?,?,?)');
$log->error("Couldn't prepare querie; aborting") unless (defined $sth); $log->error("Couldn't prepare querie; aborting") unless (defined $sth);
$sth->execute($content{'site'}, $content{'url'}, $sth->execute($content{'site'}, $content{'url'},
$content{'author'}, $content{'title'}, $content{'duration'}) $content{'author'}, $content{'title'}, $content{'duration'});
or $log->error("Couldn't finish transaction: " . $dbh->errstr);
$dbh->commit;
};
if ($@) {
$log->error("Couldn't finish transaction: " . $@);
}
} }
# sélection de l'id de la vidéo insérée # sélection de l'id de la vidéo insérée
......
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