19 Nov '13, 1am

Rescue StandardError, Not Exception

Rescue StandardError, Not Exception Jon Yurek November 18, 2013 ruby Sometimes our Ruby programs throw errors which we don't have full control over, such as network timeouts. So, we need to catch and handle those errors. To do so, we need to choose an Exception -descended class (or classes) to catch. What's the right granularity of that class? The rescued class must descend from Exception Ruby's Exception class hierarchy starts with Exception . If we try to raise an object that is not an Exception , Ruby complains. begin raise 1234.0 rescue => error puts error.inspect end Results in: #<TypeError: exception class/object expected> The default is StandardError By default, rescue only catches things that are StandardError s. To rescue something that isn't a StandardError , we have to specify: begin raise Exception.new rescue Exception => error puts "Correct!" end Results in: C...

Full article: http://robots.thoughtbot.com/rescue-standarderror-not-exc...

Tweets

Rescue StandardError, not Exception

rubyflow.com 19 Nov '13, 2am

Rescue StandardError, not Exception Posted by croaky on November 19, 2013 — 0 comments Sometimes our Ruby programs throw e...

We had a total blast at the swanky event: HSUS Raises Over 1.6M for Animals at To the Rescue Gala

We had a total blast at the swanky event: HSUS ...

ecorazzi.com 18 Nov '13, 7pm

Throughout the night celebrities came on stage and told their personal stories, like Mayor Bloomberg’s daughter bringing h...