From 0b26b5cdd5cac6d64fce788cf621a1a7a1fd3c87 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 18 Apr 2013 01:45:23 +0200 Subject: [PATCH] Improved error handling. --- lib/session.rb | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/session.rb b/lib/session.rb index 202408355..496adb51c 100644 --- a/lib/session.rb +++ b/lib/session.rb @@ -65,16 +65,18 @@ module Session session_file = @path + '/' + client_id.to_s + '/session' data = nil return if !File.exist? session_file - File.open( session_file, 'rb' ) { |file| - file.flock( File::LOCK_EX ) - all = file.read - file.flock( File::LOCK_UN ) - begin + begin + File.open( session_file, 'rb' ) { |file| + file.flock( File::LOCK_EX ) + all = file.read + file.flock( File::LOCK_UN ) data = Marshal.load( all ) - rescue - return - end - } + } + rescue Exception => e + puts "Error reading '#{session_file}':" + puts e.inspect + return + end return data end