2023-09-07 18:00:53 -05:00
//
// J I T E r r o r . s w i f t
// A l t J I T
//
// C r e a t e d b y R i l e y T e s t u t o n 9 / 3 / 2 3 .
// C o p y r i g h t © 2 0 2 3 R i l e y T e s t u t . A l l r i g h t s r e s e r v e d .
//
import Foundation
extension JITError
{
enum Code : Int , ALTErrorCode
{
typealias Error = JITError
case processNotRunning
2023-09-08 14:15:55 -05:00
case dependencyNotFound
2023-09-07 18:00:53 -05:00
}
static func processNotRunning ( _ process : AppProcess , file : StaticString = #file , line : Int = #line ) -> JITError {
JITError ( code : . processNotRunning , process : process , sourceFile : file , sourceLine : UInt ( line ) )
}
2023-09-08 14:15:55 -05:00
static func dependencyNotFound ( _ dependency : String ? , file : StaticString = #file , line : Int = #line ) -> JITError {
let errorFailure = NSLocalizedString ( " AltServer requires additional dependencies to enable JIT on iOS 17. " , comment : " " )
return JITError ( code : . dependencyNotFound , errorFailure : errorFailure , dependency : dependency , faq : " https://faq.altstore.io/how-to-use-altstore/altjit " , sourceFile : file , sourceLine : UInt ( line ) )
}
2023-09-07 18:00:53 -05:00
}
struct JITError : ALTLocalizedError
{
let code : Code
var errorTitle : String ?
var errorFailure : String ?
@ UserInfoValue var process : AppProcess ?
2023-09-08 14:15:55 -05:00
@ UserInfoValue var dependency : String ?
@ UserInfoValue var faq : String ? // S h o w u s e r F A Q U R L i n A l t S t o r e e r r o r l o g .
2023-09-07 18:00:53 -05:00
var sourceFile : StaticString ?
var sourceLine : UInt ?
var errorFailureReason : String {
switch self . code
{
case . processNotRunning :
let targetName = self . process ? . description ? ? NSLocalizedString ( " The target app " , comment : " " )
return String ( format : NSLocalizedString ( " %@ is not running. " , comment : " " ) , targetName )
2023-09-08 14:15:55 -05:00
case . dependencyNotFound :
let dependencyName = self . dependency . map { " ' \( $0 ) ' " } ? ? NSLocalizedString ( " A required dependency " , comment : " " )
return String ( format : NSLocalizedString ( " %@ is not installed. " , comment : " " ) , dependencyName )
2023-09-07 18:00:53 -05:00
}
}
var recoverySuggestion : String ? {
switch self . code
{
case . processNotRunning : return NSLocalizedString ( " Make sure the app is running in the foreground on your device then try again. " , comment : " " )
2023-09-08 14:15:55 -05:00
case . dependencyNotFound : return NSLocalizedString ( " Please follow the instructions on the AltStore FAQ to install all required dependencies, then try again. " , comment : " " )
2023-09-07 18:00:53 -05:00
}
}
}