class Beaneater::UnexpectedResponse
Abstract class for errors that occur when a command does not complete successfully.
Constants
- ERROR_STATES
Set of status states that are considered errors
Attributes
cmd[R]
@!attribute status
@return [String] returns beanstalkd response status @example @ex.status # => "NOT_FOUND"
@!attribute cmd
@return [String] returns beanstalkd request command @example @ex.cmd # => "stats-job 23"
status[R]
@!attribute status
@return [String] returns beanstalkd response status @example @ex.status # => "NOT_FOUND"
@!attribute cmd
@return [String] returns beanstalkd request command @example @ex.cmd # => "stats-job 23"
Public Class Methods
from_status(status, cmd)
click to toggle source
Translate beanstalkd error status to ruby Exeception
@param [String] status Beanstalkd error status @param [String] cmd Beanstalkd request command
@return [Beaneater::UnexpectedResponse] Exception for the status provided @example
Beaneater::UnexpectedResponse.new('NOT_FOUND', 'bury 123')
# File lib/beaneater/errors.rb, line 46 def self.from_status(status, cmd) error_klazz_name = status.split('_').map { |w| w.capitalize }.join error_klazz_name << "Error" unless error_klazz_name =~ /Error$/ error_klazz = Beaneater.const_get(error_klazz_name) error_klazz.new(status, cmd) end
new(status, cmd)
click to toggle source
Initialize unexpected response error
@param [Beaneater::UnexpectedResponse] status Unexpected response object @param [String] cmd Beanstalkd request command
@example
Beaneater::UnexpectedResponse.new(NotFoundError, 'bury 123')
Calls superclass method
# File lib/beaneater/errors.rb, line 32 def initialize(status, cmd) @status, @cmd = status, cmd super("Response failed with: #{status}") end