[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

why does this prog still stop after exception

Junkone

9/18/2008 2:05:00 PM

i thought i put enough exception handlers for the prog to continue
after failure. why does it stop
require 'imDaveAlerts'
require "timeoutx"

while(true)
puts Time.now
begin
TimeoutX.timeout(15){
begin
a=DaveAlerts.new
a.doAlerts()
rescue => detail
print detail.backtrace.join("\n")
end
}
rescue => detail
print detail.backtrace.join("\n")
end
sleep(5)
end

Wc:/ruby/lib/ruby/gems/1.8/gems/timeoutx-0.3.0/lib/timeoutx.rb:40:in
`wait': execution expired (TimeoutX::Error)
from c:/ruby/lib/ruby/gems/1.8/gems/xmpp4r-0.3.2/lib/xmpp4r/
semaphore.rb:23:in `synchronize'
from c:/ruby/lib/ruby/gems/1.8/gems/xmpp4r-0.3.2/lib/xmpp4r/
semaphore.rb:23:in `wait'
from c:/ruby/lib/ruby/gems/1.8/gems/xmpp4r-0.3.2/lib/xmpp4r/stream.rb:
284:in `wait'
from c:/ruby/lib/ruby/gems/1.8/gems/xmpp4r-0.3.2/lib/xmpp4r/stream.rb:
349:in `send'
from c:/ruby/lib/ruby/gems/1.8/gems/xmpp4r-0.3.2/lib/xmpp4r/stream.rb:
379:in `send_with_id'
from c:/ruby/lib/ruby/gems/1.8/gems/xmpp4r-0.3.2/lib/xmpp4r/client.rb:
184:in `auth_nonsasl'
from c:/ruby/lib/ruby/gems/1.8/gems/xmpp4r-0.3.2/lib/xmpp4r/client.rb:
113:in `auth'
from ./sendIM.rb:14:in `sendMessage'
from ./imDaveAlerts.rb:20:in `doAlerts'
from ./imDaveAlerts.rb:17:in `each'
from ./imDaveAlerts.rb:17:in `doAlerts'
from myCron.rb:10
from c:/ruby/lib/ruby/gems/1.8/gems/timeoutx-0.3.0/lib/timeoutx.rb:
58:in `timeout'
from myCron.rb:7
1 Answer

Stefano Crocco

9/18/2008 2:08:00 PM

0

Alle Thursday 18 September 2008, Junkone ha scritto:
> i thought i put enough exception handlers for the prog to continue
> after failure. why does it stop
> require 'imDaveAlerts'
> require "timeoutx"
>
> while(true)
> puts Time.now
> begin
> TimeoutX.timeout(15){
> begin
> a=DaveAlerts.new
> a.doAlerts()
> rescue => detail
> print detail.backtrace.join("\n")
> end
> }
> rescue => detail
> print detail.backtrace.join("\n")
> end
> sleep(5)
> end
>
> Wc:/ruby/lib/ruby/gems/1.8/gems/timeoutx-0.3.0/lib/timeoutx.rb:40:in
> `wait': execution expired (TimeoutX::Error)

If no exception class is specified, rescue only rescues exceptions derived
from StandardError, which TimeoutX::Error is not. If you want to rescue all
exceptions, you need to explicitly write

rescue Exception

I hope this helps

Stefano