Exception: MatrixSdk::MatrixRequestError
- Inherits:
-
MatrixError
- Object
- StandardError
- MatrixError
- MatrixSdk::MatrixRequestError
- Defined in:
- lib/matrix_sdk/errors.rb
Overview
An error specialized and raised for failed requests
Direct Known Subclasses
MatrixConflictError, MatrixForbiddenError, MatrixNotAuthorizedError, MatrixNotFoundError, MatrixTooManyRequestsError
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#httpstatus ⇒ Object
readonly
Returns the value of attribute httpstatus.
-
#message ⇒ Object
(also: #error)
readonly
Returns the value of attribute message.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(error, status) ⇒ MatrixRequestError
constructor
A new instance of MatrixRequestError.
- #to_s ⇒ Object
Constructor Details
#initialize(error, status) ⇒ MatrixRequestError
Returns a new instance of MatrixRequestError.
29 30 31 32 33 34 35 36 |
# File 'lib/matrix_sdk/errors.rb', line 29 def initialize(error, status) @code = error[:errcode] @httpstatus = status @message = error[:error] @data = error.reject { |k, _v| %i[errcode error].include? k } super error[:error] end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
10 11 12 |
# File 'lib/matrix_sdk/errors.rb', line 10 def code @code end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
10 11 12 |
# File 'lib/matrix_sdk/errors.rb', line 10 def data @data end |
#httpstatus ⇒ Object (readonly)
Returns the value of attribute httpstatus.
10 11 12 |
# File 'lib/matrix_sdk/errors.rb', line 10 def httpstatus @httpstatus end |
#message ⇒ Object (readonly) Also known as: error
Returns the value of attribute message.
10 11 12 |
# File 'lib/matrix_sdk/errors.rb', line 10 def @message end |
Class Method Details
.class_by_code(code) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/matrix_sdk/errors.rb', line 13 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
25 26 27 |
# File 'lib/matrix_sdk/errors.rb', line 25 def self.new_by_code(data, code) class_by_code(code).new(data, code) end |
Instance Method Details
#to_s ⇒ Object
38 39 40 |
# File 'lib/matrix_sdk/errors.rb', line 38 def to_s "HTTP #{httpstatus} (#{code}): #{}" end |