Sha256: a601ba84d8c64067abc876c6e9de1d4676d3c858075a2ab448c00c629812e344

Contents?: true

Size: 380 Bytes

Versions: 7

Compression:

Stored size: 380 Bytes

Contents

# frozen_string_literal: true

class RestClient
  class ApiError < StandardError
    attr_reader :response

    def self.[](code)
      case code
      when 404
        NotFoundError
      else
        ApiError
      end
    end

    def initialize(response)
      @response = response
      super(response.error_message)
    end
  end

  class NotFoundError < ApiError
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
wcc-media-client-0.2.4 lib/rest_client/api_error.rb
wcc-media-client-0.2.3 lib/rest_client/api_error.rb
wcc-media-client-0.2.2 lib/rest_client/api_error.rb
wcc-media-client-0.2.1 lib/rest_client/api_error.rb
wcc-media-client-0.2.0 lib/rest_client/api_error.rb
wcc-media-client-0.1.1 lib/rest_client/api_error.rb
wcc-media-client-0.1.0 lib/rest_client/api_error.rb