'rbuf_fill': execution expired (Timeout::Error)
Sun Dec 09 04:41:00 -0800 2007
This is a fun little exception in Ruby that you have to catch explicitly in order to get hold of it in a rescue block.
Say you had the following:
1 2 3 4 5 6 7 |
require 'net/pop3' begin Net::POP3.auth_only(@server, @port, @username, @password) rescue => e write_error_to_logfile(e) do_something_sensible end |
And the mail server could not be reached due to transient network problems -> that is, you are getting a socket timeout error.
Well, your code in the rescue block won’t get executed! Even though the script raises an Error!
Why is this?
Simple answer, because Timeout::Error is not a subclass of StandardError, it is a subclass of the Interrupt class.
So, that means you have to catch it explicitly, like so:
1 2 3 4 5 6 7 8 9 10 |
require 'net/pop3' begin Net::POP3.auth_only(@server, @port, @username, @password) rescue => e write_error_to_logfile(e) do_something_sensible rescue Timeout::Error => e write_error_to_logfile(e) do_something_sensible_for_timeout end |
And all will be good again, error caught!
blogLater
Mikel
Leave a Reply
Latest posts
- Put your mailer where the action is!
- Why Force a Choice?
- How to make an RSS feed in Rails
- Rails 3 Routing with Rack
- Bundle me some Rails
- Helping out in Haiti
- Watch your self
- Is Rails 3.0 a Game Changer?
- Where did the scripts go?
- validates :rails_3, :awesome => true
- New Rails Version 3.0 Guides Online
- New ActionMailer API in Rails 3.0
- Mail gem version 2 released
- How to rename a Rails 3 Application
- Rails 3.0 Examples
- DECCA Driving Day
- Mail now merged into ActionMailer
- Tip #29 - Stop a Mongrel (or any) Service in Windows
- Ruby on Rails Tips Page
- Monitoring a DAHDI or Zaptel Channel
- Mail gets some compliments!
- Rails Unit Tests: uninitialized constant error
- New Mail gem released
- Mail and Bounced Emails
- Mail, TMail, The Future of Ruby Email Handling
- Custom Music on Hold for Asterisk
- Always getting an invalid authenticity token error
- Windows ipconfig does not show anything
- FreeBSD rc scripts
- How to monitor a logged in professional
- TMail Moves to GIT
- Funny...
- How to reset a sequence with PostgreSQL
- OpenBSD RAID and Temp Sensors on HP Proliant DL 360 and 380 Series
- Terminator - Timeout without Mercy
- Tip #28 - Separate the things that change from the things that stay the same
- Fortune...
- Examples of Behaviour Spec'n
- Tip #27 - Spec a Behaviour, Not an Implementation
- Tip #26 - Start Small
- Tip #25 - Logging is your friend...
- Tip #24 - Being clever in specs is for dummies
- Tip #23 - Know your fundamentals
- Convert Visual Basic / Microsoft Long Integer Color Values to CSS RGB Format
- It's amazing what you find...
- RSpec Story xhr problem
- Tip #22 - How to ask a question about Rails
- Tip #21 - Developer Info On Every Page
- And now for something completely different...
- Rails 2.1 is out
Latest comments
Tag Cloud
AJAX ARGH! ActiveRecord Ajax Apache Apple Asterisk Australia Copy Database Development Feedburner Gem server Google Human Rights Javascript L. Ron Hubbard MS SQL Server MacOSX Mail Mephisto Not Programming OpenBSD Opensource Performance Personal Integrity PostgreSQL Programming Prototype Puzzle RDoc REST RESTful Rails RSPec RSpec Rails Rails Tips Rspec Ruby Ruby on Rails Ruby on Rails Tips Ruby on rails Tips SQL SQLServer SVN Scientologist Scientology Site Stats Soekris Soekris net5501 TMail Textmate Tips Windows World about mikel anti drug apache contributing daemon documentation drugs illustrator javascript lambda mail mephisto newspapers nitro open source opensource photoshop productivity programming railscasts rspec ruby ruby on rails rubyforge scientology seo sitemap sqlserver tips tmail tom cruise unix tricks vector graphicsArchives
- November 2009 (1)
- October 2009 (2)
- September 2009 (2)
- August 2009 (0)
- July 2009 (1)
- June 2009 (0)
- May 2009 (1)
- April 2009 (0)
- March 2009 (0)
- February 2009 (0)
- January 2009 (2)
- December 2008 (0)
- November 2008 (5)
- October 2008 (0)
- September 2008 (1)
- August 2008 (0)
- July 2008 (2)
- June 2008 (13)
- May 2008 (7)
- April 2008 (18)
- March 2008 (8)
- February 2008 (5)
- January 2008 (7)
- December 2007 (20)
- November 2007 (22)

Mon Dec 17 11:10:09 -0800 2007
Thank you very much ;)
Thu Jan 10 17:14:02 -0800 2008
Thanks, I had this same error and this cleared up my incorrect expectation that everything derived from a root Exception class.
Mon Jan 28 22:57:55 -0800 2008
http://blog.nicksieger.com/articles/2006/09/06/rubys-exception-hierarchy
Every exception derives from Exception, so you can do
begin # Thing that throws Timeouts, anything… rescue Exception => e puts ”#{e}\n#{e.backtrace.join(”\n”)}” end
Wed Feb 20 02:14:41 -0800 2008
this was a huge help!
Fri Feb 29 14:43:10 -0800 2008
This was e great help to me too… Thanks a lot!
Thu Mar 13 21:01:33 -0700 2008
Thanks, this error was really driving me crazy.
Thu Jun 12 20:23:40 -0700 2008
Thanks !
Mon Aug 25 23:20:00 -0700 2008
that was very helpful, thanks!
Wed Sep 10 17:54:23 -0700 2008
Thanks. this saved my debugging time.
Thu Sep 25 07:54:57 -0700 2008
Thx!!!
Thu Nov 06 18:04:26 -0800 2008
thank you, this was very helpful
Sat Dec 06 07:06:08 -0800 2008
This was a great help. Small, concise, exactly what I needed. Thx alot
Mon May 11 20:51:54 -0700 2009
Very helpful – accurate and to the point. Thank you!
Wed Jun 10 04:36:57 -0700 2009
Thanks! Found this on first google search, instantly fixed!
Mon Jul 06 15:57:55 -0700 2009
Thank you very much. But…. so lame…
Sun Aug 16 23:52:29 -0700 2009
You should not have a catch-all rescue anyway.
“rescue => e” == EVIL.
Mon Aug 17 03:16:19 -0700 2009
@Colin
You don’t want to rescue Exception, because then even the syntax errors in your code will be rescued by the rescue clause.
I still don’t understand why the Timeout exceptions aren’t a subclass of StandardError…