class Ridley::Errors::HTTPError
Attributes
env[R]
errors[R]
message[R]
to_s[R]
Public Class Methods
error_map()
click to toggle source
# File lib/ridley/errors.rb, line 107 def error_map @@error_map ||= Hash.new end
fabricate(env)
click to toggle source
# File lib/ridley/errors.rb, line 92 def fabricate(env) klass = lookup_error(env[:status].to_i) klass.new(env) end
lookup_error(status)
click to toggle source
# File lib/ridley/errors.rb, line 101 def lookup_error(status) error_map.fetch(status.to_i) rescue KeyError HTTPUnknownStatus end
new(env)
click to toggle source
# File lib/ridley/errors.rb, line 118 def initialize(env) @env = env @errors = env[:body].is_a?(Hash) ? Array(env[:body][:error]) : [] if errors.empty? @message = env[:body] || "no content body" else @message = "errors: " @message << errors.collect { |e| "'#{e}'" }.join(', ') end end
register_error(status)
click to toggle source
# File lib/ridley/errors.rb, line 97 def register_error(status) error_map[status.to_i] = self end