Exception: ChgkRating::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/chgk_rating/error.rb

Constant Summary collapse

ClientError =
Class.new(self)
ServerError =
Class.new(self)
EagerLoadingNotSupported =
Class.new(ClientError) do
  def to_s
    'Eager loading is not supported for this resource.'
  end
end
NotHashType =
Class.new(ClientError) do
  def to_s
    'This is not a hash-like collection, so it cannot be converted to an ordinary hash.'
  end
end
NotArrayType =
Class.new(ClientError) do
  def to_s
    'This is not an array-like collection, so it cannot be converted to an ordinary array.'
  end
end
BadRequest =
Class.new(ServerError)
NotFound =
Class.new(ServerError)
NotImplemented =
Class.new(ServerError)
ERRORS =
{
  400 => ChgkRating::Error::BadRequest,
  404 => ChgkRating::Error::NotFound,
  501 => ChgkRating::Error::NotImplemented
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = '') ⇒ Error

Initializes a new Error object



44
45
46
# File 'lib/chgk_rating/error.rb', line 44

def initialize(message = '')
  super(message)
end

Class Method Details

.from_response(body) ⇒ Object

Create a new error from an HTTP response



38
39
40
# File 'lib/chgk_rating/error.rb', line 38

def from_response(body)
  new(body.to_s)
end