2023-07-24 15:49:26 +02:00
|
|
|
//
|
2023-08-24 14:18:04 -07:00
|
|
|
// 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
|
2023-07-24 15:49:26 +02:00
|
|
|
//
|
|
|
|
|
// 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)"
|
|
|
|
|
}
|
2023-07-24 15:49:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)"
|
2023-07-24 15:49:26 +02:00
|
|
|
} else {
|
|
|
|
|
return self.underlyingError.localizedDescription
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var recoverySuggestion: String? {
|
|
|
|
|
self.underlyingError.localizedRecoverySuggestion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|