Sha256: f8ded995c6b454ae2c2c5f9eb6714a863788062ffe600cdfa36caeba076ce2b8

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

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

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

        super(to_hash)
      end

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

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

        super(to_hash)
      end

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

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

        super(to_hash)
      end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
esplanade-1.5.0 lib/esplanade/response/error.rb
esplanade-1.4.0 lib/esplanade/response/error.rb