Sha256: e7eacb698173063c6cb1d2cc86593e73a8efb41da029abe8c9012a5edc58bb06

Contents?: true

Size: 1.28 KB

Versions: 6

Compression:

Stored size: 1.28 KB

Contents

module SequenceServer

  # API errors have an http status, title, message, and additional information
  # like stacktrace or information from program output.
  class APIError < StandardError
  end

  # Job not found (404).
  class NotFound < APIError
    def http_status
      404
    end

    def title
      'Job not found'
    end

    def message
      'The requested job could not be found'
    end

    undef_method :backtrace
  end

  # Errors caused due to incorrect user input.
  class InputError < APIError
    def initialize(more_info)
      @more_info = more_info
      super
    end

    def http_status
      400
    end

    def title
      'Input error'
    end

    def message
<<MSG
Looks like there's a problem with one of the query sequences, selected
databases, or advanced parameters.
MSG
    end

    attr_reader :more_info
  end

  # Errors caused by everything other than invalid user input.
  class SystemError < APIError
    def http_status
      500
    end

    def title
      'Job failed'
    end

    def message
<<MSG
Sorry BLAST failed - please try again. If this message persists, there is a
problem with the server. In this case, please report the bug on our
<a href="https://github.com/wurmlab/sequenceserver/issues" target="_blank">
issue tracker</a>.
MSG
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sequenceserver-1.1.0.beta10 lib/sequenceserver/api_errors.rb
sequenceserver-1.1.0.beta8 lib/sequenceserver/api_errors.rb
sequenceserver-1.1.0.beta7 lib/sequenceserver/api_errors.rb
sequenceserver-1.1.0.beta6 lib/sequenceserver/api_errors.rb
sequenceserver-1.1.0.beta5 lib/sequenceserver/api_errors.rb
sequenceserver-1.1.0.beta4 lib/sequenceserver/api_errors.rb