100% free for Open Source, forever. Get another set of eyes on your code.

Take a look. Our new design is currently in beta, but you can start using it today!

A
 

Echowrap::Error::ClientError

Updated more than 3 months ago.

No issues here.

Congrats! Give yourself time to reflect on your awesome coding skillz.

require 'echowrap/error'

module Echowrap
  class Error
    # Raised when Echowrap returns a 4xx HTTP status code or there's an error in Faraday
    class ClientError < Echowrap::Error

      # Create a new error from an HTTP environment
      #
      # @param response [Hash]
      # @return [Echowrap::Error]
      def self.from_response(response={})
        new(parse_error(response[:body]), response[:response_headers])
      end

    private

      def self.parse_error(body)
        body[:response][:status][:message]
      end

    end
  end
end
10
Complexity
0
Duplication
24
Lines
2
Methods
5.2
Complexity / M
0
Churn
14
Lines of Code
7
LOC / Method