Sha256: 98a419a962cf4fc6353d10d29c3692fa2d34fe08c9136e4030b7b2aa07fbb77c
Contents?: true
Size: 1.17 KB
Versions: 171
Compression:
Stored size: 1.17 KB
Contents
# frozen_string_literal: true module Dor module Services class Client # Format HTTP response-related errors class ResponseErrorFormatter DEFAULT_BODY = "Response from dor-services-app did not contain a body. \ Check honeybadger for dor-services-app for backtraces, \ and look into adding a `rescue_from` in dor-services-app \ to provide more details to the client in the future" def self.format(response:, object_identifier: nil) new(response: response, object_identifier: object_identifier).format end attr_reader :reason_phrase, :status, :body, :object_identifier def initialize(response:, object_identifier: nil) @reason_phrase = response.reason_phrase @status = response.status @body = response.body.present? ? response.body : DEFAULT_BODY @object_identifier = object_identifier end def format return "#{reason_phrase}: #{status} (#{body})" if object_identifier.nil? "#{reason_phrase}: #{status} (#{body}) for #{object_identifier}" end end end end end
Version data entries
171 entries across 171 versions & 1 rubygems