Sha256: 008ce51ef686bde350c02f47f78e6bb1b762a6fdefa4c264effa8b14e674cf27

Contents?: true

Size: 848 Bytes

Versions: 2

Compression:

Stored size: 848 Bytes

Contents

module Sanford

  BaseError = Class.new(RuntimeError)

  NotFoundError = Class.new(RuntimeError)

  class NoHostError < BaseError
    attr_reader :message

    def initialize(host_name)
      message = if Sanford.hosts.empty?
        "No hosts have been defined. Please define a host before trying to run Sanford."
      else
        "A host couldn't be found with the name #{host_name.inspect}. "
      end
      super message
    end

  end

  class InvalidHostError < BaseError

    def initialize(host)
      super "A port must be configured or provided to run a server for '#{host}'"
    end

  end

  class NoHandlerClassError < BaseError

    def initialize(handler_class_name)
      super "Sanford couldn't find the service handler '#{handler_class_name}'. " \
        "It doesn't exist or hasn't been required in yet."
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sanford-0.3.0 lib/sanford/exceptions.rb
sanford-0.2.0 lib/sanford/exceptions.rb