class MatrixSdk::MatrixRequestError

An error specialized and raised for failed requests

Attributes

code[R]
data[R]
error[R]
httpstatus[R]
message[R]

Public Class Methods

class_by_code(code) click to toggle source
# 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(error, status) click to toggle source
Calls superclass method
# 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
new_by_code(data, code) click to toggle source
# File lib/matrix_sdk/errors.rb, line 25
def self.new_by_code(data, code)
  class_by_code(code).new(data, code)
end

Public Instance Methods

to_s() click to toggle source
# File lib/matrix_sdk/errors.rb, line 38
def to_s
  "HTTP #{httpstatus} (#{code}): #{message}"
end