From c2900b0bf2602a226fe6a940d53e3081c267e7b6 Mon Sep 17 00:00:00 2001 From: Adam Sanderson Date: Sat, 11 Dec 2010 14:07:47 -0800 Subject: [PATCH] Protect against errors in custom initialization scripts. --- lib/qwandry/launcher.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/qwandry/launcher.rb b/lib/qwandry/launcher.rb index e2f36e5..4d3dc0c 100644 --- a/lib/qwandry/launcher.rb +++ b/lib/qwandry/launcher.rb @@ -102,7 +102,13 @@ module Qwandry if config_dir = Qwandry.config_dir custom_path = File.join(config_dir, 'init.rb') if File.exist?(custom_path) - eval IO.read(custom_path) + begin + eval IO.read(custom_path), nil, custom_path, 1 + rescue Exception=>ex + STDERR.puts "Warning: error in custom file: #{custom_path.inspect}" + STDERR.puts "Exception: #{ex.message}" + STDERR.puts ex.backtrace + end end end end