module Pinterest::Errors
A list of errors returned by the client.
Constants
- CODES
A dictionary that associates HTTP status codes to error classes.
Public Class Methods
class_for_code(status)
click to toggle source
Get the class for a HTTP status code.
@param status [Fixnum] The HTTP status code. @return [Class] The class.
# File lib/pinterest/errors.rb, line 89 def self.class_for_code(status) klass = ::Pinterest::Errors::CODES.fetch(status, "ServerError") Object.const_get("::Pinterest::Errors::#{klass}") end
create(response)
click to toggle source
Creates a new error.
@param response [Faraday::Response] The network response. @return [BaseError] A error object.
# File lib/pinterest/errors.rb, line 78 def self.create(response) status = response.status message = response.body["error"] || response.body["message"] class_for_code(status).new(status, message, response.env) end