Sha256: b25a737cd22aeca7dae5b8ec11bc8c53370fb4edcfbe2d291e80a428fe31dceb

Contents?: true

Size: 1.97 KB

Versions: 6

Compression:

Stored size: 1.97 KB

Contents

# This file defines all possible exceptions that can be thrown by
# NeuroHmmerApp on startup.
#
# Exceptions only ever inform another entity (downstream code or users) of an
# issue. Exceptions may or may not be recoverable.
#
# Error classes should be seen as: the error code (class name), human readable
# message (to_s method), and necessary attributes to act on the error.
#
# We define as many error classes as needed to be precise about the issue, thus
# making it easy for downstream code (bin/genevalidatorapp or config.ru) to act
# on them.

module NeuroHmmerApp
  # Error in config file.
  class CONFIG_FILE_ERROR < StandardError
    def initialize(ent, err)
      @ent = ent
      @err = err
    end

    attr_reader :ent, :err

    def to_s
      <<MSG
Error reading config file: #{ent}.
#{err}
MSG
    end
  end

  ## ENOENT ##

  # Name borrowed from standard Errno::ENOENT, this class serves as a template
  # for defining errors that mean "expected to find <entity> at <path>, but
  # didn't".
  #
  # ENOENT is raised if and only if an entity was set, either using CLI or
  # config file. For instance, it's compulsory to set database_dir. But ENOENT
  # is not raised if database_dir is not set. ENOENT is raised if database_dir
  # was set, but does not exist.
  class ENOENT < StandardError
    def initialize(des, ent)
      @des = des
      @ent = ent
    end

    attr_reader :des, :ent

    def to_s
      "Could not find #{des}: #{ent}"
    end
  end

  # Raised if bin dir set, but does not exist.
  class BIN_DIR_NOT_FOUND < ENOENT
    def initialize(ent)
      super 'bin dir', ent
    end
  end

  # Raised if extension file set, but does not exist.
  class EXTENSION_FILE_NOT_FOUND < ENOENT
    def initialize(ent)
      super 'extension file', ent
    end
  end

  ## NUM THREADS ##

  # Raised if num_threads set by the user is incorrect.
  class NUM_THREADS_INCORRECT < StandardError
    def to_s
      'Number of threads should be a number greater than or equal to 1.'
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
neurohmmerapp-0.0.6 lib/neurohmmerapp/exceptions.rb
neurohmmerapp-0.0.5 lib/neurohmmerapp/exceptions.rb
neurohmmerapp-0.0.4 lib/neurohmmerapp/exceptions.rb
neurohmmerapp-0.0.3 lib/neurohmmerapp/exceptions.rb
neurohmmerapp-0.0.2 lib/neurohmmerapp/exceptions.rb
neurohmmerapp-0.0.1 lib/neurohmmerapp/exceptions.rb