Sha256: 0c1fb2257f4c5d2a6e9281a3c90337bbc0cfa9b7a8378962d21e4c1c9c9e6fa4

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

module Rbnotes
  ##
  # A base class for each error class of rbnotes.

  class Error < StandardError; end

  # :stopdoc:

  module ErrMsg
    MISSING_ARGUMENT  = "missing argument: %s"
    MISSING_TIMESTAMP = "missing timestamp: %s"
    INVALID_TIMESTAMP_STRING = "invalid string as timestamp: %s"
    NO_EDITOR         = "No editor is available: %s"
    PROGRAM_ABORT     = "External program was aborted: %s"
  end

  # :startdoc:

  ##
  # An error raised if an essential argument was missing.

  class MissingArgumentError < Error
    def initialize(args)
      super(ErrMsg::MISSING_ARGUMENT % args.to_s)
    end
  end

  ##
  # An error raised if a given timestamp was not found in the
  # repository.

  class MissingTimestampError < Error
    def initialize(timestamp)
      super(ErrMsg::MISSING_TIMESTAMP % timestamp)
    end
  end

  ##
  # An error raised if an argument is invalid to convert a
  # Textrepo::Timestamp object.

  class InvalidTimestampStringError < Error
    def initialize(str)
      super(ErrMsg::INVALID_TIMESTAMP_STRING % str)
    end
  end

  ##
  # An error raised if no external editor is available to edit a note,
  # even "nano" or "vi".

  class NoEditorError < Error
    def initialize(names)
      super(ErrMsg::NO_EDITOR % names.to_s)
    end
  end

  ##
  # An error raised when a external program such an editor was aborted
  # during its execution.

  class ProgramAbortError < Error
    def initialize(cmdline)
      super(ErrMsg::PROGRAM_ABORT % cmdline.join(" "))
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rbnotes-0.3.0 lib/rbnotes/error.rb