Sha256: ac4252f4b5ca2676deca642c182b62b2a14aaeb57ca612058fa0c65ffa782557

Contents?: true

Size: 785 Bytes

Versions: 1

Compression:

Stored size: 785 Bytes

Contents

# Formats a message string into application/problem+json format.

module PactBroker
  module Api
    module Decorators
      class RuntimeErrorProblemJSONDecorator

        # @param message [String]
        def initialize(message)
          @message = message
        end

        # @return [Hash]
        def to_hash(decorator_options = {})
          {
            "title" => "Server error",
            "type" => "#{decorator_options.dig(:user_options, :base_url)}/problems/server_error",
            "detail" => message,
            "status" => 500
          }
        end

        # @return [String] JSON
        def to_json(decorator_options = {})
          to_hash(decorator_options).to_json
        end

        private

        attr_reader :message
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pact_broker-2.106.0 lib/pact_broker/api/decorators/runtime_error_problem_json_decorator.rb