Sha256: 3e25e82c2966a7257651e3733acb024b4703e49861d1567ab92274d9b655cd35

Contents?: true

Size: 815 Bytes

Versions: 3

Compression:

Stored size: 815 Bytes

Contents

module Methadone
  # Standard exception you can throw to exit with a given 
  # status code. Prefer Methadone::Main#exit_now! over this
  class Error < StandardError
    attr_reader :exit_code
    # Create an Error with the given status code and message
    def initialize(exit_code,message=nil)
      super(message)
      @exit_code = exit_code
    end
  end

  # Thrown by certain methods when an externally-called command exits nonzero
  class FailedCommandError < Error

    # The command that caused the failure
    attr_reader :command

    def initialize(exit_code,command,custom_error_message = nil)
      error_message = String(custom_error_message).empty? ?  "Command '#{command}' exited #{exit_code}" : custom_error_message
      super(exit_code,error_message)
      @command = command
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
methadone-1.0.0.rc5 lib/methadone/error.rb
methadone-1.0.0.rc4 lib/methadone/error.rb
methadone-1.0.0.rc3 lib/methadone/error.rb