Files
purchases-ios/RevenueCatUI/Data/LocalizedAlertError.swift
T

45 lines
1.1 KiB
Swift
Raw Normal View History

//
// 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
//
// LocalizedAlertError.swift
//
// Created by Nacho Soto on 7/21/23.
import RevenueCat
import SwiftUI
struct LocalizedAlertError: LocalizedError {
private let underlyingError: NSError
init(error: NSError) {
self.underlyingError = error
}
var errorDescription: String? {
2024-01-16 16:27:32 -08:00
if self.underlyingError is ErrorCode {
return "Error"
} else {
return "\(self.underlyingError.domain) \(self.underlyingError.code)"
}
}
var failureReason: String? {
if let errorCode = self.underlyingError as? ErrorCode {
2024-01-16 16:27:32 -08:00
return "Error \(self.underlyingError.code): \(errorCode.description)"
} else {
return self.underlyingError.localizedDescription
}
}
var recoverySuggestion: String? {
self.underlyingError.localizedRecoverySuggestion
}
}