Sha256: 19ec17aed5f6c23f893b417bef9486eca88aa0224c2498ee31dfe13572be4ddd

Contents?: true

Size: 1.3 KB

Versions: 5

Compression:

Stored size: 1.3 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
    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
    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
    end

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

  class ContextMissingError < ::StandardError
  end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
simple-service-0.1.6 lib/simple/service/errors.rb
simple-service-0.1.5 lib/simple/service/errors.rb
simple-service-0.1.4 lib/simple/service/errors.rb
simple-service-0.1.3 lib/simple/service/errors.rb
simple-service-0.1.2 lib/simple/service/errors.rb