Skip to content

Commit

Permalink
Handle 'phased rollout already finished' error
Browse files Browse the repository at this point in the history
  • Loading branch information
kitallis committed Oct 17, 2024
1 parent 845b6eb commit e20e30e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
22 changes: 21 additions & 1 deletion lib/app_store/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@ def as_json
end
end

class PhasedReleaseAlreadyFinalError < StandardError
MSG = "The current phased release is already finished"

def initialize(msg = MSG)
super
end

def as_json
AppStore.error_as_json(:release, :phased_release_already_final, MSG)
end
end

class PhasedReleaseNotFoundError < StandardError
MSG = "The current live release does not have a staged rollout"

Expand Down Expand Up @@ -231,13 +243,15 @@ def as_json
end
end

# 404
NOT_FOUND_ERRORS = [
AppStore::AppNotFoundError,
AppStore::BuildNotFoundError,
AppStore::BetaGroupNotFoundError,
AppStore::LocalizationNotFoundError
]

# 422
ERRORS = [
AppStore::ExportComplianceNotFoundError,
AppStore::BuildSubmissionForReviewNotAllowedError,
Expand All @@ -251,5 +265,11 @@ def as_json
AppStore::VersionNotEditableError
]

CONFLICT_ERRORS = [AppStore::PhasedReleaseAlreadyInStateError, AppStore::ReleaseNotEditableError, AppStore::ReleaseAlreadyHaltedError]
# 409
CONFLICT_ERRORS = [
AppStore::PhasedReleaseAlreadyInStateError,
AppStore::PhasedReleaseAlreadyFinalError,
AppStore::ReleaseNotEditableError,
AppStore::ReleaseAlreadyHaltedError
]
end
16 changes: 10 additions & 6 deletions spaceship/wrapper_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ class WrapperError
decorated_exception: AppStore::BuildSubmissionForReviewNotAllowedError
},
{
message_matcher: /You cannot update when the value is already set. - \/data\/attributes\/usesNonExemptEncryption/,
message_matcher: %r{You cannot update when the value is already set. - /data/attributes/usesNonExemptEncryption},
decorated_exception: AppStore::ExportComplianceAlreadyUpdatedError
},
{
message_matcher: /The phased release already has this value - \/data\/attributes\/phasedReleaseState/,
message_matcher: %r{The phased release already has this value - /data/attributes/phasedReleaseState},
decorated_exception: AppStore::PhasedReleaseAlreadyInStateError
},
{
message_matcher: /You cannot create a new version of the App in the current state/,
decorated_exception: AppStore::VersionAlreadyAddedToSubmissionError
},
{
message_matcher: /The version number has been previously used. - \/data\/attributes\/versionString/,
message_matcher: %r{The version number has been previously used. - /data/attributes/versionString},
decorated_exception: AppStore::VersionAlreadyExistsError
},
{
message_matcher: /An attribute value is not acceptable for the current resource state. - The attribute 'versionString' can not be modified. - \/data\/attributes\/versionString/,
message_matcher: %r{An attribute value is not acceptable for the current resource state. - The attribute 'versionString' can not be modified. - /data/attributes/versionString},
decorated_exception: AppStore::VersionNotEditableError
},
{
message_matcher: /A relationship value is not acceptable for the current resource state. - The specified pre-release build could not be added. - \/data\/relationships\/build/,
message_matcher: %r{A relationship value is not acceptable for the current resource state. - The specified pre-release build could not be added. - /data/relationships/build},
decorated_exception: AppStore::VersionNotEditableError
},
{
Expand All @@ -40,8 +40,12 @@ class WrapperError
{
message_matcher: /Attachment uploads still in progress/i,
decorated_exception: AppStore::AttachmentUploadInProgress
},
{
message_matcher: /You cannot change the state of a phased release that is in a final state/i,
decorated_exception: AppStore::PhasedReleaseAlreadyFinalError
}
]
].freeze

def self.handle(exception)
new(exception).handle
Expand Down

0 comments on commit e20e30e

Please sign in to comment.