From 04c6eb32b4b8ed8027a1c8fd934c3f53b5353f9a Mon Sep 17 00:00:00 2001 From: Denis Knauf Date: Sun, 21 Mar 2010 00:59:45 +0100 Subject: [PATCH] bin/box.rb: Lesser Backtrace --- bin/box.rb | 9 +++++---- lib/safebox/box.rb | 8 ++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/bin/box.rb b/bin/box.rb index 670ee03..a6540a5 100755 --- a/bin/box.rb +++ b/bin/box.rb @@ -8,19 +8,20 @@ rescue LoadError end require 'safebox' -_ = nil +_ = _e = nil Dir.mkdir 'logs' rescue Errno::EEXIST SBDB::Env.new 'logs', SBDB::CREATE | SBDB::Env::INIT_TRANSACTION do |logs| - db = logs['test', :type => SBDB::Btree, :flags => SBDB::CREATE] + db = logs[ 'test', :type => SBDB::Btree, :flags => SBDB::CREATE] db = Safebox::Persistent.new db, db.cursor $stdout.print "(0)$ " STDIN.each_with_index do |line, i| - ret = Safebox.run line, Safebox::Box, db, _ + ret = Safebox.run line, Class.new( Safebox::Box), db, _, _e if :value == ret.first _ = ret.last $stdout.puts "=> #{ret.last.inspect}" else - $stdout.puts ret.last.inspect, ret.last.backtrace.map( &" %s".method( :%)) + _e = ret.last + $stdout.puts ret.last.inspect, ret.last.backtrace[0..-4].map( &"\t%s".method( :%)), "\tSafebox:1:in `run'" end $stdout.print "(#{i+1})$ " end diff --git a/lib/safebox/box.rb b/lib/safebox/box.rb index 77d8f0b..c85133f 100644 --- a/lib/safebox/box.rb +++ b/lib/safebox/box.rb @@ -3,8 +3,12 @@ require 'safebox/safebox' class Safebox::Box attr_reader :_, :db - def initialize db, _ = nil - @_, @db = _, db + def initialize db, _ = nil, _e + @_, @db, @_e = _, db, _e + end + + def _! + @_e end def put key, val