The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Rescue exit

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jonathan Weiss

Posts: 146
Nickname: jweiss
Registered: Jan, 2006

Jonathan Weiss is a Ruby and BSD enthusiast
Rescue exit Posted: Aug 21, 2009 7:18 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Jonathan Weiss.
Original Post: Rescue exit
Feed Title: BlogFish
Feed URL: http://blog.innerewut.de/feed/atom.xml
Feed Description: Weblog by Jonathan Weiss about Unix, BSD, security, Programming in Ruby, Ruby on Rails and Agile Development.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Jonathan Weiss
Latest Posts From BlogFish

Advertisement

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.

Read: Rescue exit

Topic: Staying Current: A Software Developer's Responsibility Previous Topic   Next Topic Topic: rubygems-isit19 1.0

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use