Sha256: b945f04f997184fd0d82b964b558fa3a62b8e7f837f1e23d5c5f0586acf2b564

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

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

    class PrefixNotMatch < Error; end

    class NotDocumented < Error
      def initialize(request:, status:)
        @method = request[:method]
        @path = request[:path]
        @raw_path = request[:raw_path]
        @status = status

        super(to_hash)
      end

      def to_hash
        {
          request:
            {
              method: @method,
              path: @path,
              raw_path: @raw_path
            },
          status: @status
        }
      end
    end

    class BodyIsNotJson < Error
      def initialize(request:, status:, body:)
        @method = request[:method]
        @path = request[:path]
        @raw_path = request[:raw_path]
        @status = status
        @body = body

        super(to_hash)
      end

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

    class Invalid < Error
      def initialize(request:, status:, body:, error:)
        @method = request[:method]
        @path = request[:path]
        @raw_path = request[:raw_path]
        @status = status
        @body = body
        @error = error

        super(to_hash)
      end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
esplanade-1.7.1 lib/esplanade/response/error.rb
esplanade-1.7.0 lib/esplanade/response/error.rb
esplanade-1.6.0 lib/esplanade/response/error.rb