Sha256: a4dc32538829ca8f8f9a87b0dc72cf3e595e226cb9f91ce7eab0bc4199a4ceaf

Contents?: true

Size: 984 Bytes

Versions: 49

Compression:

Stored size: 984 Bytes

Contents

class Shelly::Client
  class APIException < Exception
    attr_reader :status_code, :body, :request_id

    def initialize(body = {}, status_code = nil, request_id = nil)
      @status_code = status_code
      @body = body
      @request_id = request_id
    end

    def [](key)
      body[key.to_s]
    end
  end

  class UnauthorizedException < APIException; end

  class ForbiddenException < APIException; end

  class ConflictException < APIException; end

  class GemVersionException < APIException; end

  class GatewayTimeoutException < APIException; end

  class LockedException < APIException; end

  class ValidationException < APIException
    def errors
      self[:errors]
    end

    def each_error
      errors.each do |field, message|
        yield [field.gsub('_',' ').capitalize, message].join(" ")
      end
    end
  end

  class NotFoundException < APIException
    def resource
      self[:resource].to_sym
    end

    def id
      self[:id]
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
shelly-0.4.34 lib/shelly/client/errors.rb
shelly-0.4.33 lib/shelly/client/errors.rb
shelly-0.4.32 lib/shelly/client/errors.rb
shelly-0.4.31 lib/shelly/client/errors.rb
shelly-0.4.30 lib/shelly/client/errors.rb
shelly-0.4.29 lib/shelly/client/errors.rb
shelly-0.4.29.pre lib/shelly/client/errors.rb
shelly-0.4.28 lib/shelly/client/errors.rb
shelly-0.4.28.pre2 lib/shelly/client/errors.rb
shelly-0.4.28.pre lib/shelly/client/errors.rb
shelly-0.4.27 lib/shelly/client/errors.rb
shelly-0.4.26 lib/shelly/client/errors.rb
shelly-0.4.26.pre lib/shelly/client/errors.rb
shelly-0.4.25 lib/shelly/client/errors.rb
shelly-0.4.24 lib/shelly/client/errors.rb
shelly-0.4.23 lib/shelly/client/errors.rb
shelly-0.4.23.pre lib/shelly/client/errors.rb
shelly-0.4.22 lib/shelly/client/errors.rb
shelly-0.4.21 lib/shelly/client/errors.rb
shelly-0.4.19 lib/shelly/client/errors.rb