root / examples / exception.rb
| 1 | #!/usr/bin/env ruby
|
|---|---|
| 2 | |
| 3 | $:.push File.join( File.dirname(__FILE__), "..", "lib" ) |
| 4 | |
| 5 | require 'dramatis/actor'
|
| 6 | |
| 7 | $serial = false |
| 8 | |
| 9 | if ARGV[0] == "serial" |
| 10 | $serial = true |
| 11 | end
|
| 12 | |
| 13 | class Foo |
| 14 | if !$serial |
| 15 | include Dramatis::Actor |
| 16 | end
|
| 17 | def foo that |
| 18 | return that.bar -3 |
| 19 | end
|
| 20 | end
|
| 21 | |
| 22 | class Bar |
| 23 | if !$serial |
| 24 | include Dramatis::Actor |
| 25 | end
|
| 26 | def bar value |
| 27 | fooobar |
| 28 | end
|
| 29 | def foobar |
| 30 | "foobar"
|
| 31 | end
|
| 32 | end
|
| 33 | |
| 34 | Foo.new
|
| 35 | begin
|
| 36 | Foo.new.foo Bar.new |
| 37 | rescue NameError => ne |
| 38 | puts "hey, I got a #{ne}"
|
| 39 | puts "it happened here: " + ne.backtrace.join("\n") |
| 40 | end
|