work around CGI::Session constructor issues

The constructor can fail with a useless error message if module fail to
load. Work around this by evaling it, and checking for failures, and
printing CGI::Session->errstr to get a more useful message.
master
Joey Hess 2008-07-10 13:16:03 -04:00
parent f00e5a8a89
commit 5d26ded381
1 changed files with 8 additions and 2 deletions

View File

@ -645,8 +645,14 @@ sub cgi_getsession ($) { #{{{
CGI::Session->name("ikiwiki_session_".encode_utf8($config{wikiname}));
my $oldmask=umask(077);
my $session = CGI::Session->new("driver:DB_File", $q,
{ FileName => "$config{wikistatedir}/sessions.db" });
my $session = eval {
CGI::Session->new("driver:DB_File", $q,
{ FileName => "$config{wikistatedir}/sessions.db" })
};
if (! $session || $@) {
error($@." ".CGI::Session->errstr());
}
umask($oldmask);
return $session;