bin/box.rb: Lesser Backtrace
This commit is contained in:
parent
054be00221
commit
04c6eb32b4
2 changed files with 11 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue