Exception: Lightstreamer::LightstreamerError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/lightstreamer/errors.rb,
lib/lightstreamer/errors.rb

Overview

Base class for all errors raised by this gem.

Class Method Summary collapse

Class Method Details

.build(message, code) ⇒ LightstreamerError

Takes a Lightstreamer error message and numeric code and returns an instance of the relevant error class that should be raised in response to the error.

Parameters:

  • message (String)

    The error message.

  • code (Fixnum)

    The numeric error code that is used to determine which Lightstreamer::LightstreamerError subclass to instantiate.

Returns:



188
189
190
191
192
193
194
195
196
197
198
# File 'lib/lightstreamer/errors.rb', line 188

def self.build(message, code)
  code = code.to_i

  if API_ERROR_CODE_TO_CLASS.key? code
    API_ERROR_CODE_TO_CLASS[code].new ''
  elsif code <= 0
    Errors::MetadataAdapterError.new message, code
  else
    new "#{code}: #{message}"
  end
end