Sha256: c210d6a78ed5d35a0a27a3fa6bc0c77102326aa7b77ac4bdec3ce411b38f09ff

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

module Simple::Service
  # Will be raised by ::Simple::Service.action.
  class NoSuchAction < ::ArgumentError
    attr_reader :service, :name

    def initialize(service, name)
      @service, @name = service, name
      super()
    end

    def to_s
      action_names = ::Simple::Service.actions(service).keys.sort
      informal = "service #{service} has these actions: #{action_names.map(&:inspect).join(", ")}"
      "No such action #{name.inspect}; #{informal}"
    end
  end

  class ArgumentError < ::ArgumentError
  end

  class MissingArguments < ArgumentError
    attr_reader :action
    attr_reader :parameters

    def initialize(action, parameters)
      @action, @parameters = action, parameters
      super()
    end

    def to_s
      "#{action}: missing argument(s): #{parameters.map(&:to_s).join(", ")}"
    end
  end

  class ExtraArguments < ArgumentError
    attr_reader :action
    attr_reader :arguments

    def initialize(action, arguments)
      @action, @arguments = action, arguments
      super()
    end

    def to_s
      str = @arguments.map(&:inspect).join(", ")
      "#{action}: extra argument(s) #{str}"
    end
  end

  class ContextReadOnlyError < ::StandardError
    def initialize(key)
      super "Cannot overwrite existing context setting #{key.inspect}"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
simple-service-0.2.2 lib/simple/service/errors.rb
simple-service-0.2.1 lib/simple/service/errors.rb
simple-service-0.2.0 lib/simple/service/errors.rb