Sha256: a0f831d8341afd13a795bcfe6ab9bdc480b67c9fbaa1467c369fbef84005b83f

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

module MySpace
  # Parent class of our local exceptions
  class MySpaceException < Exception
  end

  # You tried to pass an invalid value as a parameter to a REST call.
  # The REST error responses are not very elucidating, so we try to
  # catch these before sending them off.
  class BadIdentifier < MySpaceException
    attr_reader :parameter, :identifier
    def initialize(parameter, identifier)
      @parameter = parameter
      @identifier = identifier
    end
  end

  # A REST call failed for some reason.
  class RestException < MySpaceException
    attr_reader :code, :message, :url
    def initialize(code, message, url)
      @code = code
      @message = message
      @url = url
    end

    def to_s
      "#<MySpace::RestException: #{@code}: '#{@message}' loading '#{@url}'>"
    end
  end

  # A REST call failed because the caller doesn't have permission to
  # call it.
  class PermissionDenied < RestException
    def to_s
      "#<PermissionDenied loading '#{url}'>"
    end
  end

  # A REST call timed out.  Should probably just try again.
  class TimeoutException < Interrupt
    attr_accessor :url, :timeout
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
myspaceid-sdk-0.1.11 lib/myspace/exceptions.rb
myspaceid-sdk-0.1.9 lib/myspace/exceptions.rb