bin/box.rb: Lesser Backtrace

This commit is contained in:
Denis Knauf 2010-03-21 00:59:45 +01:00
parent 054be00221
commit 04c6eb32b4
2 changed files with 11 additions and 6 deletions

View file

@ -8,19 +8,20 @@ rescue LoadError
end end
require 'safebox' require 'safebox'
_ = nil _ = _e = nil
Dir.mkdir 'logs' rescue Errno::EEXIST Dir.mkdir 'logs' rescue Errno::EEXIST
SBDB::Env.new 'logs', SBDB::CREATE | SBDB::Env::INIT_TRANSACTION do |logs| 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 db = Safebox::Persistent.new db, db.cursor
$stdout.print "(0)$ " $stdout.print "(0)$ "
STDIN.each_with_index do |line, i| 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 if :value == ret.first
_ = ret.last _ = ret.last
$stdout.puts "=> #{ret.last.inspect}" $stdout.puts "=> #{ret.last.inspect}"
else 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 end
$stdout.print "(#{i+1})$ " $stdout.print "(#{i+1})$ "
end end

View file

@ -3,8 +3,12 @@ require 'safebox/safebox'
class Safebox::Box class Safebox::Box
attr_reader :_, :db attr_reader :_, :db
def initialize db, _ = nil def initialize db, _ = nil, _e
@_, @db = _, db @_, @db, @_e = _, db, _e
end
def _!
@_e
end end
def put key, val def put key, val