Sha256: 6f7c0266b5f67363f1725481f033dd77db53c43190dda080985f8c28235d103d

Contents?: true

Size: 1.91 KB

Versions: 9

Compression:

Stored size: 1.91 KB

Contents

module Esplanade
  class Request
    class Error < Esplanade::Error; end

    class PrefixNotMatch < Error; end

    class NotDocumented < Error
      def initialize(method:, path:, raw_path:, content_type:)
        @method = method
        @path = path
        @raw_path = raw_path
        @content_type = content_type

        super(to_hash)
      end

      def to_hash
        {
          method: @method,
          path: @path,
          raw_path: @raw_path,
          content_type: @content_type
        }
      end
    end

    class ContentTypeIsNotJson < Error
      def initialize(method:, path:, raw_path:, content_type:)
        @method = method
        @raw_path = raw_path
        @path = path
        @content_type = content_type

        super(to_hash)
      end

      def to_hash
        {
          method: @method,
          path: @path,
          raw_path: @raw_path,
          content_type: @content_type
        }
      end
    end

    class BodyIsNotJson < Error
      def initialize(method:, path:, raw_path:, content_type:, body:)
        @method = method
        @path = path
        @raw_path = raw_path
        @content_type = content_type
        @body = body

        super(to_hash)
      end

      def to_hash
        {
          method: @method,
          path: @path,
          raw_path: @raw_path,
          content_type: @content_type,
          body: @body
        }
      end
    end

    class Invalid < Error
      def initialize(method:, path:, raw_path:, content_type:, body:, error:)
        @method = method
        @path = path
        @raw_path = raw_path
        @content_type = content_type
        @body = body
        @error = error

        super(to_hash)
      end

      def to_hash
        {
          method: @method,
          path: @path,
          raw_path: @raw_path,
          content_type: @content_type,
          body: @body,
          error: @error
        }
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
esplanade-1.8.5 lib/esplanade/request/error.rb
esplanade-1.8.4 lib/esplanade/request/error.rb
esplanade-1.8.3 lib/esplanade/request/error.rb
esplanade-1.8.2 lib/esplanade/request/error.rb
esplanade-1.8.1 lib/esplanade/request/error.rb
esplanade-1.8.0 lib/esplanade/request/error.rb
esplanade-1.7.1 lib/esplanade/request/error.rb
esplanade-1.7.0 lib/esplanade/request/error.rb
esplanade-1.6.0 lib/esplanade/request/error.rb