Sha256: 2db4c4c0019836cc75db5f9fbb8f2751e9a3f44518081b6795d8f9551f8f3ae8

Contents?: true

Size: 602 Bytes

Versions: 9

Compression:

Stored size: 602 Bytes

Contents

module DocRaptor
  class ApiError < StandardError
    attr_reader :code, :response_headers, :response_body

    # Usage examples:
    #   ApiError.new
    #   ApiError.new("message")
    #   ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
    #   ApiError.new(:code => 404, :message => "Not Found")
    def initialize(arg = nil)
      if arg.is_a? Hash
        arg.each do |k, v|
          if k.to_s == 'message'
            super v
          else
            instance_variable_set "@#{k}", v
          end
        end
      else
        super arg
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
docraptor-1.1.0 lib/docraptor/api_error.rb
docraptor-1.0.0 lib/docraptor/api_error.rb
docraptor-0.4.0 lib/docraptor/api_error.rb
docraptor-0.3.0 lib/docraptor/api_error.rb
docraptor-0.2.0 lib/docraptor/api_error.rb
docraptor-0.1.0 lib/docraptor/api_error.rb
docraptor-0.0.3 lib/docraptor/api_error.rb
docraptor-0.0.2 lib/docraptor/api_error.rb
docraptor-0.0.1 lib/docraptor/api_error.rb