lib/dor/services/client/metadata.rb in dor-services-client-2.3.0 vs lib/dor/services/client/metadata.rb in dor-services-client-2.4.0
- old
+ new
@@ -9,29 +9,31 @@
def initialize(connection:, version:, object_identifier:)
super(connection: connection, version: version)
@object_identifier = object_identifier
end
- # @return [String] The Dublin Core XML representation of the object
+ # @return [String, NilClass] The Dublin Core XML representation of the object or nil if response is 404
+ # @raise [UnexpectedResponse] on an unsuccessful response from the server
def dublin_core
resp = connection.get do |req|
req.url "#{base_path}/dublin_core"
end
return resp.body if resp.success?
return if resp.status == 404
- raise UnexpectedResponse, "#{resp.reason_phrase}: #{resp.status} (#{resp.body}) for #{object_identifier}"
+ raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp, object_identifier: object_identifier)
end
- # @return [String] The descriptive metadata XML representation of the object
+ # @return [String, NilClass] The descriptive metadata XML representation of the object or nil if response is 404
+ # @raise [UnexpectedResponse] on an unsuccessful response from the server
def descriptive
resp = connection.get do |req|
req.url "#{base_path}/descriptive"
end
return resp.body if resp.success?
return if resp.status == 404
- raise UnexpectedResponse, "#{resp.reason_phrase}: #{resp.status} (#{resp.body}) for #{object_identifier}"
+ raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp, object_identifier: object_identifier)
end
private
attr_reader :object_identifier