Skip to content

Commit

Permalink
Beaneater::NotConnected error initializes with a connection instance
Browse files Browse the repository at this point in the history
  • Loading branch information
avgerin0s committed Feb 12, 2015
1 parent 355cb98 commit 487e486
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/beaneater/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def config
# Raises an error to be triggered when the connection has failed
# @raise [Beaneater::NotConnected] Beanstalkd is no longer connected
def raise_not_connected!
raise NotConnected, "Connection to beanstalk '#{@host}:#{@port}' is closed!"
raise NotConnected.new(self), "Connection to beanstalk '#{@host}:#{@port}' is closed!"
end
end # Connection
end # Beaneater
20 changes: 19 additions & 1 deletion lib/beaneater/errors.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
module Beaneater
# Raises when a beanstalkd instance is no longer accessible.
class NotConnected < RuntimeError; end
class NotConnected < RuntimeError
# @!attribute connection
# @return [Connection] returns the connection that errored
# @example @ex.connection # => #<Beaneater::Connection host="localhost" port=11300>
attr_reader :connection

# Initialize connection error
#
# @param [Beaneater::Connection] the connection that errored
#
# @example
# Beaneater::UnexpectedResponse.new(NotConnected, conn)
#
def initialize(connection)
@connection = connection
super
end
end

# Raises when the tube name specified is invalid.
class InvalidTubeName < RuntimeError; end
# Raises when a job has not been reserved properly.
Expand Down

0 comments on commit 487e486

Please sign in to comment.