class WOTC::Error
Custom error class for rescuing from all wotc.com errors
Attributes
errors[R]
http_method[R]
url[R]
Public Class Methods
new(response)
click to toggle source
Calls superclass method
# File lib/wotc/error.rb, line 6 def initialize(response) super @response = response.dup @http_method = response.method.to_s @url = response.url if response.body.is_a?(Hash) && !response.body.empty? && !response.body.fetch("errors", nil).nil? @raw_errors = response.body.fetch("errors") end end
Public Instance Methods
error_sentence()
click to toggle source
# File lib/wotc/error.rb, line 29 def error_sentence return if @raw_errors.nil? array = [] @raw_errors.each do |_, v| array += v end array.join(' ') end
message()
click to toggle source
# File lib/wotc/error.rb, line 16 def message <<-HEREDOC URL: #{@response.url} method: #{@response.method} response status: #{@response.status} response body: #{@response.response.body} HEREDOC end
raw_errors()
click to toggle source
# File lib/wotc/error.rb, line 25 def raw_errors @raw_errors end