class YNAB::ApiError
Attributes
code[R]
response_body[R]
response_headers[R]
Public Class Methods
new(arg = nil)
click to toggle source
Usage examples:
ApiError.new ApiError.new("message") ApiError.new(:code => 500, :response_headers => {}, :response_body => "") ApiError.new(:code => 404, :message => "Not Found")
Calls superclass method
# File lib/ynab/api_error.rb, line 22 def initialize(arg = nil) if arg.is_a? Hash if arg.key?(:message) || arg.key?('message') super(arg[:message] || arg['message']) else super arg end arg.each do |key, value| if respond_to?("#{key}=") send "#{key}=", value else instance_variable_set "@#{key}", value end end else super arg end end
Public Instance Methods
detail()
click to toggle source
# File lib/ynab/api_error.rb, line 60 def detail (@error_parsed || {}).fetch('error', {})['detail'] end
id()
click to toggle source
# File lib/ynab/api_error.rb, line 52 def id (@error_parsed || {}).fetch('error', {})['id'] end
name()
click to toggle source
# File lib/ynab/api_error.rb, line 56 def name (@error_parsed || {}).fetch('error', {})['name'] end
response_body=(value)
click to toggle source
# File lib/ynab/api_error.rb, line 42 def response_body=(value) @response_body = value begin @error_parsed = JSON.parse(value) rescue @error_parsed = nil end end