Exception: SteamCondenser::Error::WebApi

Inherits:
SteamCondenser::Error show all
Defined in:
lib/steam-condenser/error/web_api.rb

Overview

This error is raised when a Steam Web API request or a related action fails. This can have various reasons like an invalid Web API key or a broken request.

See Also:

Author:

  • Sebastian Staudt

Instance Attribute Summary

Attributes inherited from SteamCondenser::Error

#cause

Instance Method Summary collapse

Constructor Details

#initialize(cause, status_code = nil, status_message = '') ⇒ WebApi

Creates a new Error::WebApi with an error message according to the given cause. If this cause is :status_bad (which will origin from the Web API itself) or :http_error the details about this failed request will be taken from status_code and status_message.


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/steam-condenser/error/web_api.rb', line 45

def initialize(cause, status_code = nil, status_message = '')
  case cause
    when :http_error then
      message = "The Web API request has failed due to an HTTP error: #{status_message} (status code: #{status_code})."
    when :invalid_key then
      message = 'This is not a valid Steam Web API key.'
    when :status_bad then
      message = "The Web API request failed with the following error: #{status_message} (status code: #{status_code})."
    when :unauthorized then
      message = 'Your Web API request has been rejected. You most likely did not specify a valid Web API key.'
    else
      message = 'An unexpected error occured while executing a Web API request.'
  end

  super message
end