Sha256: e6beda67255264ba80b929038c8ec25bd9fad8256ce5f097437acc0b772d8eee

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

# frozen-string-literal: true

module Down
  # generic error which is a superclass to all other errors
  class Error < StandardError; end

  # raised when the file is larger than the specified maximum size
  class TooLarge < Error; end

  # raised when the given URL couldn't be parsed
  class InvalidUrl < Error; end

  # raised when the number of redirects was larger than the specified maximum
  class TooManyRedirects < Error; end

  # raised when response returned 4xx or 5xx response
  class ResponseError < Error
    attr_reader :response

    def initialize(message, response: nil)
      super(message)
      @response = response
    end
  end

  # raised when response returned 4xx response
  class ClientError < ResponseError; end

  # raised when response returned 404 response
  class NotFound < ClientError; end

  # raised when response returned 5xx response
  class ServerError < ResponseError; end

  # raised when there was an error connecting to the server
  class ConnectionError < Error; end

  # raised when connecting to the server too longer than the specified timeout
  class TimeoutError < ConnectionError; end

  # raised when an SSL error was raised
  class SSLError < Error; end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
down-5.0.1 lib/down/errors.rb
down-5.0.0 lib/down/errors.rb