Sha256: 180e11028a37d1e0d20dadf7f79b37fc3344e1b4804d7c0328dd3f48d198128c

Contents?: true

Size: 1.49 KB

Versions: 11

Compression:

Stored size: 1.49 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

    def more_info
      ''
    end
  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 initialize(more_info = nil)
      @more_info = more_info || backtrace
      super
    end

    def http_status
      500
    end

    def title
      'System error'
    end

    def message
      <<~MSG
        Looks like there is a problem with the server. Try visiting the page again
        after a while. If this message persists, please report the problem on our
        <a href="https://github.com/wurmlab/sequenceserver/issues" target="_blank">
        issue tracker</a>.
      MSG
    end

    attr_reader :more_info
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
sequenceserver-2.0.0.rc8 lib/sequenceserver/api_errors.rb
sequenceserver-2.0.0.rc7 lib/sequenceserver/api_errors.rb
sequenceserver-2.0.0.rc6 lib/sequenceserver/api_errors.rb
sequenceserver-2.0.0.rc5 lib/sequenceserver/api_errors.rb
sequenceserver-2.0.0.rc4 lib/sequenceserver/api_errors.rb
sequenceserver-2.0.0.rc3 lib/sequenceserver/api_errors.rb
sequenceserver-2.0.0.rc2 lib/sequenceserver/api_errors.rb
sequenceserver-2.0.0.rc1 lib/sequenceserver/api_errors.rb
sequenceserver-2.0.0.beta4 lib/sequenceserver/api_errors.rb
sequenceserver-2.0.0.beta3 lib/sequenceserver/api_errors.rb
sequenceserver-2.0.0.beta1 lib/sequenceserver/api_errors.rb