Exception: K2ConnectRuby::K2ConnectionError

Inherits:
K2Errors
  • Object
show all
Defined in:
lib/k2-connect-ruby/k2_errors.rb

Overview

For errors concerning the Status code returned from Kopo Kopo

Instance Attribute Summary

Attributes inherited from K2Errors

#status

Instance Method Summary collapse

Constructor Details

#initialize(error) ⇒ K2ConnectionError

Returns a new instance of K2ConnectionError.



12
13
14
# File 'lib/k2-connect-ruby/k2_errors.rb', line 12

def initialize(error)
  @error = error
end

Instance Method Details

#messageObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/k2-connect-ruby/k2_errors.rb', line 16

def message
  case @error
  when 400.to_s
    STDERR.puts("Bad Request.\n\tYour request is Invalid")
  when 401.to_s
    STDERR.puts("Unauthorized.\n Your API key is wrong")
  when 403.to_s
    STDERR.puts("Forbidden.\n The resource requested cannot be accessed")
  when 404.to_s
    STDERR.puts("Not Found.\n\tThe specified resource could not be found")
  when 405.to_s
    STDERR.puts("Method Not Allowed.\n You tried to access a resource with an invalid method")
  when 406.to_s
    STDERR.puts("Not Acceptable.\n You requested a format that isn't valid json")
  when 410.to_s
    STDERR.puts("Gone.\n The resource requested has been moved")
  when 429.to_s
    STDERR.puts("Too Many Requests.\n Request threshold has been exceeded")
  when 500.to_s
    STDERR.puts("Internal Server Error.\n We had a problem with our server. Try again later")
  when 503.to_s
    STDERR.puts("Service Unavailable.\n We're temporarily offline for maintenance. Please try again later")
  else
    STDERR.puts("Undefined Kopo Kopo Server Response.")
  end
end