Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[spaceship] Add language name in stack trace when localization operations fail #20581

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require_relative '../model'
require_relative '../../errors'
module Spaceship
class ConnectAPI
class AppInfoLocalization
Expand Down Expand Up @@ -32,11 +33,15 @@ def update(client: nil, attributes: nil)
client ||= Spaceship::ConnectAPI
attributes = reverse_attr_mapping(attributes)
client.patch_app_info_localization(app_info_localization_id: id, attributes: attributes)
rescue
raise Spaceship::AppStoreLocalizationError, @locale
end

def delete!(client: nil, filter: {}, includes: nil, limit: nil, sort: nil)
client ||= Spaceship::ConnectAPI
client.delete_app_info_localization(app_info_localization_id: id)
rescue
raise Spaceship::AppStoreLocalizationError, @locale
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require_relative '../model'
require_relative './app_preview_set'
require_relative './app_screenshot_set'
require_relative '../../errors'

module Spaceship
class ConnectAPI
Expand Down Expand Up @@ -43,23 +44,31 @@ def self.get(client: nil, app_store_version_localization_id: nil, filter: {}, in
client ||= Spaceship::ConnectAPI
resp = client.get_app_store_version_localization(app_store_version_localization_id: app_store_version_localization_id, filter: filter, includes: includes, limit: limit, sort: sort)
return resp.to_models
rescue
raise Spaceship::AppStoreLocalizationError, @locale
end

def self.all(client: nil, app_store_version_id: nil, filter: {}, includes: nil, limit: nil, sort: nil)
client ||= Spaceship::ConnectAPI
resp = client.get_app_store_version_localizations(app_store_version_id: app_store_version_id, filter: filter, includes: includes, limit: limit, sort: sort)
return resp.to_models
rescue
raise Spaceship::AppStoreLocalizationError, @locale
end

def update(client: nil, attributes: nil)
client ||= Spaceship::ConnectAPI
attributes = reverse_attr_mapping(attributes)
client.patch_app_store_version_localization(app_store_version_localization_id: id, attributes: attributes)
rescue
raise Spaceship::AppStoreLocalizationError, @locale
end

def delete!(client: nil, filter: {}, includes: nil, limit: nil, sort: nil)
client ||= Spaceship::ConnectAPI
client.delete_app_store_version_localization(app_store_version_localization_id: id)
rescue
raise Spaceship::AppStoreLocalizationError, @locale
end

#
Expand All @@ -71,12 +80,16 @@ def get_app_preview_sets(client: nil, filter: {}, includes: "appPreviews", limit
filter ||= {}
filter["appStoreVersionLocalization"] = id
return Spaceship::ConnectAPI::AppPreviewSet.all(client: client, filter: filter, includes: includes, limit: limit, sort: sort)
rescue
raise Spaceship::AppStoreAppPreviewError, @locale
end

def create_app_preview_set(client: nil, attributes: nil)
client ||= Spaceship::ConnectAPI
resp = client.post_app_preview_set(app_store_version_localization_id: id, attributes: attributes)
return resp.to_models.first
rescue
raise Spaceship::AppStoreAppPreviewError, @locale
end

#
Expand All @@ -86,12 +99,16 @@ def create_app_preview_set(client: nil, attributes: nil)
def get_app_screenshot_sets(client: nil, filter: {}, includes: "appScreenshots", limit: nil, sort: nil)
client ||= Spaceship::ConnectAPI
return Spaceship::ConnectAPI::AppScreenshotSet.all(client: client, app_store_version_localization_id: id, filter: filter, includes: includes, limit: limit, sort: sort)
rescue
raise Spaceship::AppStoreScreenshotError, @locale
end

def create_app_screenshot_set(client: nil, attributes: nil)
client ||= Spaceship::ConnectAPI
resp = client.post_app_screenshot_set(app_store_version_localization_id: id, attributes: attributes)
return resp.to_models.first
rescue
raise Spaceship::AppStoreScreenshotError, @locale
end
end
end
Expand Down
34 changes: 34 additions & 0 deletions spaceship/lib/spaceship/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,38 @@ class GatewayTimeoutError < BasicPreferredInfoError; end

# Raised when 403 is received from portal request
class AccessForbiddenError < BasicPreferredInfoError; end

# Base class for errors coming from App Store Connect locale changes
class AppStoreLocaleError < BasicPreferredInfoError
def initialize(msg)
@message = (msg ? "An exception occurred for locale: #{msg}." : nil)
super
end

# no need to search github issues since the error is specific
def show_github_issues
false
end
end

# Raised for localized text errors from App Store Connect
class AppStoreLocalizationError < AppStoreLocaleError
def preferred_error_info
"#{@message} Check the localization requirements here: https://help.apple.com/app-store-connect/en.lproj/static.html#dev354659071"
end
end

# Raised for localized screenshots errors from App Store Connect
class AppStoreScreenshotError < AppStoreLocaleError
def preferred_error_info
"#{@message} Check the screenshot requirements here: https://help.apple.com/app-store-connect/en.lproj/static.html#devd274dd925"
end
end

# Raised for localized app preview errors from App Store Connect
class AppStoreAppPreviewError < AppStoreLocaleError
def preferred_error_info
"#{@message} Check the app preview requirements here: https://help.apple.com/app-store-connect/en.lproj/static.html#dev4e413fcb8"
end
end
end