Exception: Beaneater::UnexpectedResponse
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- Beaneater::UnexpectedResponse
- Defined in:
- lib/beaneater/errors.rb
Overview
Abstract class for errors that occur when a command does not complete successfully.
Direct Known Subclasses
BadFormatError, DeadlineSoonError, DrainingError, ExpectedCrlfError, InternalError, JobTooBigError, NotFoundError, NotIgnoredError, OutOfMemoryError, TimedOutError, UnknownCommandError
Constant Summary collapse
- ERROR_STATES =
Set of status states that are considered errors
%w(OUT_OF_MEMORY INTERNAL_ERROR BAD_FORMAT UNKNOWN_COMMAND JOB_TOO_BIG DRAINING TIMED_OUT DEADLINE_SOON NOT_FOUND NOT_IGNORED EXPECTED_CRLF)
Instance Attribute Summary collapse
-
#cmd ⇒ Object
Returns the value of attribute cmd.
-
#status ⇒ String
Returns beanstalkd response status.
Class Method Summary collapse
-
.from_status(status, cmd) ⇒ Beaneater::UnexpectedResponse
Translate beanstalkd error status to ruby Exeception.
Instance Method Summary collapse
-
#initialize(status, cmd) ⇒ UnexpectedResponse
constructor
Initialize unexpected response error.
Constructor Details
#initialize(status, cmd) ⇒ UnexpectedResponse
Initialize unexpected response error
32 33 34 35 |
# File 'lib/beaneater/errors.rb', line 32 def initialize(status, cmd) @status, @cmd = status, cmd super("Response failed with: #{status}") end |
Instance Attribute Details
#cmd ⇒ Object
Returns the value of attribute cmd.
22 |
# File 'lib/beaneater/errors.rb', line 22 attr_reader :status, :cmd |
#status ⇒ String
Returns beanstalkd response status
22 23 24 |
# File 'lib/beaneater/errors.rb', line 22 def status @status end |
Class Method Details
.from_status(status, cmd) ⇒ Beaneater::UnexpectedResponse
Translate beanstalkd error status to ruby Exeception
46 47 48 49 50 51 |
# 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 |