Sha256: cc38aa001c68baa185aac80cff59fe686e7d05342b928f13dc2b15e6083578ba

Contents?: true

Size: 790 Bytes

Versions: 1

Compression:

Stored size: 790 Bytes

Contents

require 'faraday'

module AnsibleTowerClient
  class ResourceNotFound < Faraday::ResourceNotFound
    def initialize(klass, attrs = {})
      @klass  = klass
      @attrs  = attrs
      @key    = attrs.keys.first
      @value  = attrs[@key]
      super(issue_error)
    end

    def issue_error
      method = @key.nil? ? 'general' : @key
      send("#{method}_msg")
    end

    private

    def id_msg
      "Couldn't find #{@klass} with '#{@key}'=#{@value}"
    end

    def general_msg
      "Couldn't find #{@klass}"
    end
  end

  class Error < StandardError
    attr_reader :message
    def initialize(klass)
      @message = "Error on #{klass.class.name}: #{klass.inspect}"
      super(message)
    end
  end

  class InvalidHash < Error; end
  class InvalidJson < Error; end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ansible_tower_client-0.1.0 lib/ansible_tower_client/error.rb