From 5d26ded3811cd050a1c70ccf76f3022a787a9588 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 10 Jul 2008 13:16:03 -0400 Subject: 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. --- IkiWiki/CGI.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 99cead64f..52d3474f5 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -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; -- cgit v1.2.3