Updated swig_assert to optionally be more verbose
and report stack traces nicelly. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9692 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
4b8d11d0e2
commit
928f12bd44
1 changed files with 27 additions and 2 deletions
|
|
@ -11,6 +11,31 @@
|
|||
class SwigRubyError < RuntimeError
|
||||
end
|
||||
|
||||
def swig_assert( condition, *args )
|
||||
raise SwigRubyError.new("FAILED CHECK: #{condition} #{args.join(' ')}") unless eval(condition)
|
||||
class SwigAssertError < StandardError
|
||||
end
|
||||
|
||||
|
||||
def swig_assert( condition, *args )
|
||||
begin
|
||||
ok = eval(condition.to_s)
|
||||
rescue => e
|
||||
raise SwigAssertError.new("Wrong assert: #{condition.to_s} - #{e}")
|
||||
end
|
||||
|
||||
unless ok
|
||||
raise SwigRubyError.new("FAILED CHECK: #{condition} #{args.join(' ')}")
|
||||
end
|
||||
|
||||
if $VERBOSE
|
||||
$stdout.puts "\tPASSED #{condition} #{args.join(' ')}"
|
||||
end
|
||||
|
||||
return ok
|
||||
rescue => e
|
||||
trace = e.backtrace[1..-1]
|
||||
$stderr.puts "#{trace[0,1]}: #{e}"
|
||||
if trace.size > 1
|
||||
$stderr.puts "\tfrom #{trace[1..-1].join("\n\t ")}"
|
||||
end
|
||||
exit(1)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue