Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

"exit 1" breaks ones code #10

Open
wants to merge 1 commit into from

2 participants

@levmatta-umanni

Please do not swallow exceptions, and do not exit without my consent.
I simpĺy changed the code to let the exception bubble up.

@zr40 zr40 commented on the diff
lib/stalker.rb
@@ -88,10 +84,6 @@ def work_one_job
job.delete
log_job_end(name)
- rescue Beanstalk::NotConnected => e
- failed_connection(e)
- rescue SystemExit
- raise
@zr40
zr40 added a note

Don't delete this rescue SystemExit block. It prevents SystemExit from being handled and swallowed by the rescue block just below.

@zr40
zr40 added a note

Also don't delete the rescue Beanstalk::NotConnected block on line 91, for the same reason. Instead, replace failed_connection(e) with raise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 13, 2012
  1. @levmatta-umanni
This page is out of date. Refresh to see the latest.
Showing with 0 additions and 15 deletions.
  1. +0 −15 lib/stalker.rb
View
15 lib/stalker.rb
@@ -17,8 +17,6 @@ def enqueue(job, args={}, opts={})
ttr = opts[:ttr] || 120
beanstalk.use job
beanstalk.put [ job, args ].to_json, pri, delay, ttr
- rescue Beanstalk::NotConnected => e
- failed_connection(e)
end
def job(j, &block)
@@ -55,8 +53,6 @@ def prep(jobs=nil)
beanstalk.list_tubes_watched.each do |server, tubes|
tubes.each { |tube| beanstalk.ignore(tube) unless jobs.include?(tube) }
end
- rescue Beanstalk::NotConnected => e
- failed_connection(e)
end
def work(jobs=nil)
@@ -88,10 +84,6 @@ def work_one_job
job.delete
log_job_end(name)
- rescue Beanstalk::NotConnected => e
- failed_connection(e)
- rescue SystemExit
- raise
@zr40
zr40 added a note

Don't delete this rescue SystemExit block. It prevents SystemExit from being handled and swallowed by the rescue block just below.

@zr40
zr40 added a note

Also don't delete the rescue Beanstalk::NotConnected block on line 91, for the same reason. Instead, replace failed_connection(e) with raise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
rescue => e
log_error exception_message(e)
job.bury rescue nil
@@ -105,13 +97,6 @@ def work_one_job
end
end
- def failed_connection(e)
- log_error exception_message(e)
- log_error "*** Failed connection to #{beanstalk_url}"
- log_error "*** Check that beanstalkd is running (or set a different BEANSTALK_URL)"
- exit 1
- end
-
def log_job_begin(name, args)
args_flat = unless args.empty?
'(' + args.inject([]) do |accum, (key,value)|
Something went wrong with that request. Please try again.