Exception: MailRU::API::Error

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/mailru-api/error.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, description) ⇒ Error

Returns a new instance of Error.



8
9
10
11
# File 'lib/mailru-api/error.rb', line 8

def initialize code, description
  @code = Integer(code)
  @description = description
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



6
7
8
# File 'lib/mailru-api/error.rb', line 6

def code
  @code
end

#descriptionObject

Returns the value of attribute description.



6
7
8
# File 'lib/mailru-api/error.rb', line 6

def description
  @description
end

Class Method Details

.create(code, description) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/mailru-api/error.rb', line 13

def self.create(code, description)
  case code
    when 1 then UnknwonError.new(code, description)
    when 2 then UnknownMethodCalledError.new(code, description)
    when 3 then MethodIsDeprecatedError.new(code, description)
    when 100 then InvalidParameterError.new(code, description)
    when 102 then AuthorizationFailedError.new(code, description)
    when 103 then ApplicationLookupFailedError.new(code, description)
    when 104 then IncorrectSignatureError.new(code, description)
    when 105 then ApplicationIsNotInstalledError.new(code, description)
    when 200 then PermissionDeniedError.new(code, description)
    when 202 then AccessToObjectDeniedError.new(code, description)
    when 501 then IncorrectImageError.new(code, description)
    else Error.new(code, description)
  end
end