class GridRest::Error

Error class for a rest request. Has some nice features like internationalisation of messages, and basic methods to correspond with a normal request, but most importantly returns false on the valid? question.

Attributes

code[R]
message[R]
request_method[R]
response[R]
type[R]
url[R]

Public Class Methods

new(e, rparams) click to toggle source
# File lib/grid_rest.rb, line 292
def initialize(e, rparams)
  @request_method = rparams.delete(:request_method) || rparams.delete(:method)
  @code = e.respond_to?(:http_code) ? e.http_code : (rparams.delete(:code) || 500)
  @response = e.response if e.respond_to?(:response)
  @type = e.class.name.split('::').last
  @message = I18n.t(@type, :scope => [:grid_rest, :message], :default => nil)
  @url = rparams.delete(:url)
end

Public Instance Methods

array() click to toggle source

Call this on error if the result should be an empty array, but wit the invalid metadata

# File lib/grid_rest.rb, line 321
def array
  ErrorArray.new(self)
end
to_s() click to toggle source
# File lib/grid_rest.rb, line 304
def to_s
  ''
end
Also aliased as: to_str
to_str()
Alias for: to_s
try(m, *args) click to toggle source
# File lib/grid_rest.rb, line 313
def try(m, *args)
  return send(m, *args) if respond_to?(m)
  # Behave like a nil object otherwise
  nil
end
valid?() click to toggle source
# File lib/grid_rest.rb, line 309
def valid?
  false
end