Sha256: 75fa0140a3b747a20ecad8f1f69b75905761e7f130c065aae7b4bc39e9b21b47

Contents?: true

Size: 1.63 KB

Versions: 3

Compression:

Stored size: 1.63 KB

Contents

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

    class PrefixNotMatch < Error; end

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

        super(to_hash)
      end

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

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

        super(to_hash)
      end

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

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

        super(to_hash)
      end

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

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

        super(to_hash)
      end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
esplanade-1.5.0 lib/esplanade/request/error.rb
esplanade-1.4.0 lib/esplanade/request/error.rb
esplanade-1.3.0 lib/esplanade/request/error.rb