Sha256: eb3f5e54ee949e84933696c783e151a274f2ec10c2d69bc652ec836d4cd214ba

Contents?: true

Size: 743 Bytes

Versions: 8

Compression:

Stored size: 743 Bytes

Contents

module Yacli
  class YacliError < StandardError
    class << self
      # @param [Integer] code
      def status_code(code)
        define_method(:status_code) { code }
        define_singleton_method(:status_code) { code }
      end
    end

    alias message to_s
  end

  class ExecutionError < YacliError; status_code(2); end
  class InvalidExitCodeError < YacliError
    status_code(3)
    def initialize(cmd_return)
      @cmd_return = cmd_return.inspect
    end

    def to_s
      "Command output #{@cmd_return}"
    end
  end
  class InvalidContentError < YacliError
    status_code(4)
    def initialize(cmd_return)
      @cmd_return = cmd_return.inspect
    end

    def to_s
      "Command output #{@cmd_return}"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
yacli-0.3.2 lib/yacli/errors.rb
yacli-0.3.1 lib/yacli/errors.rb
yacli-0.2.5 lib/yacli/errors.rb
yacli-0.2.4 lib/yacli/errors.rb
yacli-0.2.3 lib/yacli/errors.rb
yacli-0.2.2 lib/yacli/errors.rb
yacli-0.2.1 lib/yacli/errors.rb
yacli-0.2.0 lib/yacli/errors.rb