Protect against errors in custom initialization scripts.

This commit is contained in:
Adam Sanderson 2010-12-11 14:07:47 -08:00
parent 828fb0ed76
commit c2900b0bf2
1 changed files with 7 additions and 1 deletions

View File

@ -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