dor-services-client 15.70.0 → 15.71.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2d01ad7fc1729cfbadc4a1b5b2295cb506d0c280cf3ccdad25e2d587ba6e6b0
4
- data.tar.gz: 83ffa45286a613eaff5debb049ac448f972a007c0acf48cafd32cac7fae954e2
3
+ metadata.gz: 730aef635e88c59d2124afc5c4a14bec8e5a1b6bc73e76726a647be01a97a420
4
+ data.tar.gz: 8f0b4402c3a91a00d186e15c0360d248f9f53363605702046919cba80b3ec091
5
5
  SHA512:
6
- metadata.gz: b9f74ef35fac2d94a9e4061bb8197ec91465423e1c027a0f669851d989bad7326ce36234ca8d9d339963131e1ae67ba25b6d3db8eab1d096b7db17a4b4093e44
7
- data.tar.gz: 48002be6cf8082e8ec5aba236d7d3e96b0df6feb6aebf5a30ab95c0393d54a5f15911e2e95133330ae3dad5b5c5ac0b5710b1a41a7aebc6362bd1d9987e38bc0
6
+ metadata.gz: 914ba382636b58b9d0a257066b5c1d7a60cc94155157d1d5fad943d340750f66d04d04c3b61d0b74d8bcdf1310eb21dcb3eea004ac752da5cdd077eca63d8033
7
+ data.tar.gz: eb7e38f3a6ff299338a4178378c9aad9cff096dcf4fe68f260794fddae36422b930634ea4ff3ccf4d1d2ae0c5c8ade4d74cecfdef7a87a9e1da7888253230be7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dor-services-client (15.70.0)
4
+ dor-services-client (15.71.0)
5
5
  activesupport (>= 7.0.0)
6
6
  cocina-models (~> 0.133.0)
7
7
  deprecation
data/README.md CHANGED
@@ -132,6 +132,7 @@ object_client.user_version.create(object_version: 3)
132
132
  object_client.user_version.update(user_version: Dor::Services::Client::UserVersion::Version.new(version: 3, userVersion: 3, withdrawn: true))
133
133
 
134
134
  # Return the Cocina metadata
135
+ # Raises Dor::Services::Client::InvalidCocinaError if the stored cocina is invalid.
135
136
  object_client.find
136
137
 
137
138
  # Return the Cocina metadata without the file sets (structural.contains), e.g., for objects with many files.
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Services
5
5
  class Client
6
- VERSION = '15.70.0'
6
+ VERSION = '15.71.0'
7
7
  end
8
8
  end
9
9
  end
@@ -16,6 +16,9 @@ module Dor
16
16
 
17
17
  JSON_API_MIME_TYPE = 'application/vnd.api+json'
18
18
 
19
+ # Title of the JSON:API error dor-services-app returns when stored cocina is invalid
20
+ INVALID_COCINA_TITLE = 'Invalid cocina'
21
+
19
22
  def initialize(connection:, version:)
20
23
  @connection = connection
21
24
  @api_version = version
@@ -36,10 +39,16 @@ module Dor
36
39
  else
37
40
  {}
38
41
  end
39
- exception_class = EXCEPTION_CLASS.fetch(response.status, UnexpectedResponse)
40
- raise exception_class.new(response: response,
41
- object_identifier: object_identifier,
42
- errors: data.fetch('errors', []))
42
+ errors = data.fetch('errors', [])
43
+ raise exception_class_for(response.status, errors).new(response: response,
44
+ object_identifier: object_identifier,
45
+ errors: errors)
46
+ end
47
+
48
+ def exception_class_for(status, errors)
49
+ return InvalidCocinaError if status == 500 && errors.first&.dig('title') == INVALID_COCINA_TITLE
50
+
51
+ EXCEPTION_CLASS.fetch(status, UnexpectedResponse)
43
52
  end
44
53
 
45
54
  def build_cocina_from_response(item, headers: nil, validate: false)
@@ -84,6 +84,9 @@ module Dor
84
84
  # This occurs when the request is well-formed but the content is not indexable
85
85
  class UnprocessableContentError < UnexpectedResponse; end
86
86
 
87
+ # Error that is raised when dor-services-app returns a 500 because the stored cocina is invalid
88
+ class InvalidCocinaError < UnexpectedResponse; end
89
+
87
90
  module Types
88
91
  include Dry.Types()
89
92
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dor-services-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 15.70.0
4
+ version: 15.71.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne