Exception: ActiveMatrix::Errors::MatrixRequestError

Inherits:
MatrixError
  • Object
show all
Defined in:
lib/active_matrix/errors.rb

Overview

An error specialized and raised for failed requests

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error, status) ⇒ MatrixRequestError

Returns a new instance of MatrixRequestError.



30
31
32
33
34
35
36
37
# File 'lib/active_matrix/errors.rb', line 30

def initialize(error, status)
  @code = error[:errcode]
  @httpstatus = status
  @message = error[:error]
  @data = error.except(:errcode, :error)

  super(error[:error])
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



11
12
13
# File 'lib/active_matrix/errors.rb', line 11

def code
  @code
end

#dataObject (readonly)

Returns the value of attribute data.



11
12
13
# File 'lib/active_matrix/errors.rb', line 11

def data
  @data
end

#httpstatusObject (readonly)

Returns the value of attribute httpstatus.



11
12
13
# File 'lib/active_matrix/errors.rb', line 11

def httpstatus
  @httpstatus
end

#messageObject (readonly) Also known as: error

Returns the value of attribute message.



11
12
13
# File 'lib/active_matrix/errors.rb', line 11

def message
  @message
end

Class Method Details

.class_by_code(code) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/active_matrix/errors.rb', line 14

def self.class_by_code(code)
  code = code.to_i

  return MatrixNotAuthorizedError if code == 401
  return MatrixForbiddenError if code == 403
  return MatrixNotFoundError if code == 404
  return MatrixConflictError if code == 409
  return MatrixTooManyRequestsError if code == 429

  MatrixRequestError
end

.new_by_code(data, code) ⇒ Object



26
27
28
# File 'lib/active_matrix/errors.rb', line 26

def self.new_by_code(data, code)
  class_by_code(code).new(data, code)
end

Instance Method Details

#to_sObject



39
40
41
# File 'lib/active_matrix/errors.rb', line 39

def to_s
  "HTTP #{httpstatus} (#{code}): #{message}"
end