Files
Rick ee0afe9dfc fix(checkpoints): prevent presentation conflicts from blocking future calls (#8048)
* fix(checkpoints): finish when error alert cannot be presented

* fix(checkpoints): suppress busy presentation contexts

* refactor(checkpoints): clarify unavailable presentation context
2026-10-16 17:26:02 +02:00

67 lines
2.0 KiB
Swift

//
// Copyright RevenueCat Inc. All Rights Reserved.
//
// Licensed under the MIT License (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/MIT
//
// CheckpointError.swift
//
// Created by Rick van der Linden.
//
import Foundation
@_spi(Internal) import RevenueCat
enum CheckpointError: Error {
case invalidIdentifier(String)
case configurationUnavailable
case operationAlreadyInProgress
case noPresentationContext
case presentationContextUnavailable
case presentationFailed
}
extension CheckpointError: CustomNSError {
static var errorDomain: String {
return ErrorCode.errorDomain
}
var errorCode: Int {
switch self {
case .invalidIdentifier, .configurationUnavailable, .noPresentationContext,
.presentationContextUnavailable, .presentationFailed:
return ErrorCode.configurationError.rawValue
case .operationAlreadyInProgress:
return ErrorCode.operationAlreadyInProgressForProductError.rawValue
}
}
var errorUserInfo: [String: Any] {
return [NSLocalizedDescriptionKey: self.errorDescription]
}
private var errorDescription: String {
switch self {
case let .invalidIdentifier(identifier):
return CheckpointIdentifierValidator.invalidIdentifierLogMessage(identifier)
case .configurationUnavailable:
return "Checkpoint configuration is unavailable."
case .operationAlreadyInProgress:
return "Another checkpoint UI is already being presented."
case .noPresentationContext:
return "Unable to locate a view controller for checkpoint presentation."
case .presentationContextUnavailable:
return "The checkpoint presentation context is unavailable."
case .presentationFailed:
return "Unable to present checkpoint UI."
}
}
}