Rescue exit
While debugging an unrelated problem in Nanite I've stumbled over this feature in Ruby:
You can rescue the call to Kernel.exit.
Calling exit will just raise a SystemExit exception that can catched as any other.
#!/usr/bin/env ruby
begin
exit
rescue SystemExit => e
puts "somebody wanted to #{e}"
end
puts "after exiting"
This is clearly documented in the RDoc but still I was surprised.
- Programming Language:
- Add new comment
- 181 reads
- Feed: BlogFish
- Original article


Recent comments
1 year 23 weeks ago
1 year 23 weeks ago
1 year 25 weeks ago
1 year 27 weeks ago
1 year 42 weeks ago
1 year 45 weeks ago
1 year 45 weeks ago
1 year 45 weeks ago
1 year 46 weeks ago
1 year 48 weeks ago