Commit ad268fbe authored by bensinober's avatar bensinober
Browse files

DEICH-0000: add logging of session insert failure

parent f26c7aa8
......@@ -4,7 +4,9 @@ use warnings;
# This session stores in DB, reasonable default to persist plack restart
use parent "Deichman::Auth::Session";
use Try::Tiny;
use Core::DB;
use Core::Exception;
use JSON;
our $JSON = JSON->new();
......@@ -43,8 +45,12 @@ sub _save {
$sth = $dbh->prepare("UPDATE sessions SET a_session = ?, token = ? WHERE id = ?");
$sth->execute($JSON->encode(\%data), $self->{token}, $self->{id});
} else {
$sth = $dbh->prepare("INSERT INTO sessions (a_session, id, token) VALUES (?,?,?)");
$sth->execute($JSON->encode(\%data), $self->{id}, $self->{token}) or die "insert failed";
try {
$sth = $dbh->prepare("INSERT INTO sessions (a_session, id, token) VALUES (?,?,?)");
$sth->execute($JSON->encode(\%data), $self->{id}, $self->{token}) or Core::Exception::DB::InvalidQuery->throw($dbh->errstr);
} catch {
warn "ERROR INSERTING SESSION: " . $_;
};
}
$self->{last_save} = $data{last_save};
#warn __PACKAGE__."->_save(".Dumper($self).")";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment