Sha256: 7a2a408cb2bbf93c8f02288b8bfc5740633b549b8511767c3e9ae2270fd52a6e
Contents?: true
Size: 1.37 KB
Versions: 16
Compression:
Stored size: 1.37 KB
Contents
class Fanforce class Error < StandardError; def initialize(response, request, path, query_params) @query_params = query_params @path = path @request = request begin @response = MultiJson.load(response, :symbolize_keys => symbolize_keys) rescue @response = response end @request_url = "#{@path}?#{@query_params.to_param}" super(@response.is_a?(Hash) ? @response[:message] : @response) end attr :path, :query_params, :request, :response, :request_url def curl_command case @request.method when :get "curl \"#{@path}?#{@query_params.to_param}\"" when :post "curl -X POST -d \"#{@query_params.to_param}\" #{@path}" when :put "curl -X PUT -d \"#{@query_params.to_param}\" #{@path.to_json}" when :delete "curl --request DELETE \"#{@path}?#{@query_params.to_param}\"" else "Could not create curl command because request method was unknown: #{@request.method}" end end def code() end end class BadRequestError < Error; def code() 400 end end class ForbiddenError < Error; def code() 403 end end class NotFoundError < Error; def code() 404 end end class UnprocessableEntityError < Error; def code() 422 end end class UnknownError < Error; def code() 500 end end end
Version data entries
16 entries across 16 versions & 1 rubygems