Exception: AppStoreConnectApi::ApiError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/app_store_connect_api/api_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(errors) ⇒ ApiError

Returns a new instance of ApiError.



7
8
9
10
# File 'lib/app_store_connect_api/api_error.rb', line 7

def initialize(errors)
  @errors = errors
  super 'App Store Connect API request failed'
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



5
6
7
# File 'lib/app_store_connect_api/api_error.rb', line 5

def errors
  @errors
end

Instance Method Details

#associated_errorsObject



24
25
26
27
28
29
# File 'lib/app_store_connect_api/api_error.rb', line 24

def associated_errors
  associated_errors = errors.map { |error| error.dig :meta, :associated_errors }.compact
  return [] if associated_errors.blank?

  associated_errors.map { |error_hash| error_hash.map { |_, errors| errors.pluck :detail } }.flatten
end

#codeObject



12
13
14
# File 'lib/app_store_connect_api/api_error.rb', line 12

def code
  errors.first[:code]
end

#detailsObject



20
21
22
# File 'lib/app_store_connect_api/api_error.rb', line 20

def details
  errors.map { |e| [e[:title], e[:detail]] }.flatten.uniq
end

#statusObject



16
17
18
# File 'lib/app_store_connect_api/api_error.rb', line 16

def status
  errors.first[:status].to_i
end