gixen_error.rb 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. class Gixen
  2. GIXEN_ERROR_MAP = {
  3. 501 => :ssl_required, # ERROR (501): SSL REQUIRED
  4. 100 => :could_not_log_in, # ERROR (100): COULD NOT LOG IN
  5. 101 => :could_not_log_in, # ERROR (101): COULD NOT LOG IN
  6. 1001 => :down, # ERROR (1001): GIXEN DOWN
  7. 111 => :not_subscriber, # ERROR (111): NON SUBSCRIBER
  8. 115 => :suspended, # ERROR (115): GIXEN ACCOUNT SUSPENDED
  9. 771 => :delete_failed, # ERROR (771): DELETE QUERY FAILED
  10. 772 => :delete_failed, # ERROR (772): DELETE QUERY FAILED
  11. 131 => :no_username, # ERROR (131): USERNAME NOT SPECIFIED
  12. 132 => :no_password, # ERROR (132): PASSWORD NOT SPECIFIED
  13. 133 => :no_maxbid, # ERROR (133): MAXIMUM BID NOT SPECIFIED
  14. 201 => :too_many_snipes, # ERROR (201): MAXIMUM NUMBER OF SNIPES EXCEEDED
  15. 202 => :already_present, # ERROR (202): ITEM ALREADY PRESENT
  16. 203 => :cannot_get_info, # ERROR (203): COULD NOT GET INFO FOR ITEM
  17. 301 => :format_invalid, # ERROR (301): COULD NOT ADD SNIPE: AUCTION NUMBER OR MONEY FORMAT INVALID
  18. 302 => :error_adding_to_mirror, # ERROR (302): COULD NOT ADD SNIPE TO MIRROR
  19. 304 => :error_adding_to_mirror, # ERROR (304): COULD NOT ADD SNIPE TO MIRROR
  20. 401 => :empty_authentication, # ERROR (401): EMPTY USERNAME OR EMPTY PASSWORD
  21. 241 => :delete_failed, # ERROR (241): DELETE QUERY FAILED
  22. 242 => :delete_failed # ERROR (242): DELETE QUERY FAILED
  23. }
  24. # GixenError is raised when there's a problem with the response, or
  25. # the Gixen server has returned an error.
  26. class GixenError < RuntimeError
  27. def initialize(code, text)
  28. super(text)
  29. @code = code
  30. @status = GIXEN_ERROR_MAP[@code]
  31. @message = text
  32. end
  33. attr_reader :status, :code, :message
  34. def to_s
  35. "#{code} #{status} - #{message}"
  36. end
  37. end
  38. end