diff --git a/Mythic/Controllers/Legendary/Extensions/LegendaryInterfaceExt.swift b/Mythic/Controllers/Legendary/Extensions/LegendaryInterfaceExt.swift index c8f6751f..983632e3 100644 --- a/Mythic/Controllers/Legendary/Extensions/LegendaryInterfaceExt.swift +++ b/Mythic/Controllers/Legendary/Extensions/LegendaryInterfaceExt.swift @@ -53,9 +53,13 @@ extension Legendary { case load } - struct UnableToGetPlatformError: Error { } + struct UnableToGetPlatformError: LocalizedError { + var errorDescription: String? = "Mythic is unable to get the platform of this game." + } - struct IsNotLegendaryError: Error { } + struct IsNotLegendaryError: LocalizedError { + var errorDescription: String? = "This is not an epic game." + } // GameDoesNotExistError unified! @@ -86,12 +90,15 @@ extension Legendary { /// Error when legendary is signed out on a command that enforces signin. @available(*, message: "This error will be deprecated soon, in favor of UserValidationError") - struct NotSignedInError: Error { } + struct NotSignedInError: LocalizedError { + var errorDescription: String? = "You aren't signed in to epic games" + } /// Installation error with a message, see ``Legendary.install()`` - struct InstallationError: Error { + struct InstallationError: LocalizedError { init(_ message: String) { self.message = message } let message: String + var errorDescription: String? = "Unable to install game." // TODO: message } } diff --git a/Mythic/Controllers/Wine/Extensions/WineInterfaceExt.swift b/Mythic/Controllers/Wine/Extensions/WineInterfaceExt.swift index 49c24658..d91fa942 100644 --- a/Mythic/Controllers/Wine/Extensions/WineInterfaceExt.swift +++ b/Mythic/Controllers/Wine/Extensions/WineInterfaceExt.swift @@ -42,10 +42,11 @@ extension Wine { } /// Signifies that a wineprefix is unable to boot. - struct BootError: Error { + struct BootError: LocalizedError { // TODO: proper implementation, see `Wine.boot(prefix: <#URL#>)` let reason: String? = nil + var errorDescription: String? = "Bottle unable to boot." // TODO: add reason if possible } internal enum RegistryType: String { @@ -74,5 +75,7 @@ extension Wine { } /// Signifies that a wineprefix does not exist at a specified location. - struct PrefixDoesNotExistError: Error { } + struct PrefixDoesNotExistError: LocalizedError { + var errorDescription: String? = "This bottle doesn't exist." + } } diff --git a/Mythic/Controllers/Wine/WineInterface.swift b/Mythic/Controllers/Wine/WineInterface.swift index c00378d1..a2a207cc 100644 --- a/Mythic/Controllers/Wine/WineInterface.swift +++ b/Mythic/Controllers/Wine/WineInterface.swift @@ -27,7 +27,7 @@ class Wine { // TODO: https://forum.winehq.org/viewtopic.php?t=15416 private static var runningCommands: [String: Process] = .init() /// The directory where all wine prefixes related to Mythic are stored. - static let bottlesDirectory: URL? = { // FIXME: is optional necessary in case of dir creation failure? + static let bottlesDirectory: URL? = { // FIXME: allow force-unwrapping of bottles directory, directory creation error will be rare let directory = Bundle.appContainer!.appending(path: "Bottles") if files.fileExists(atPath: directory.path) { return directory @@ -286,8 +286,8 @@ class Wine { // TODO: https://forum.winehq.org/viewtopic.php?t=15416 settings: BottleSettings = defaultBottleSettings, completion: @escaping (Result) -> Void ) async { - guard let baseURL = baseURL else { completion(.failure(NSError())); return } - guard files.fileExists(atPath: baseURL.path) else { completion(.failure(FileLocations.FileDoesNotExistError(nil))); return } + guard let baseURL = baseURL else { return } + guard files.fileExists(atPath: baseURL.path) else { completion(.failure(FileLocations.FileDoesNotExistError(baseURL))); return } let bottleURL = baseURL.appending(path: name) guard Libraries.isInstalled() else { completion(.failure(Libraries.NotInstalledError())); return } diff --git a/Mythic/Extensions/Global.swift b/Mythic/Extensions/Global.swift index 3aeeca2f..7d5bd0c8 100644 --- a/Mythic/Extensions/Global.swift +++ b/Mythic/Extensions/Global.swift @@ -55,9 +55,10 @@ func placeholderGame(_ type: GameType) -> Game { } /// Your father. -struct GameDoesNotExistError: Error { +struct GameDoesNotExistError: LocalizedError { init(_ game: Mythic.Game) { self.game = game } let game: Mythic.Game + var errorDescription: String? = "This game doesn't exist." } // MARK: - Functions diff --git a/Mythic/Localizable.xcstrings b/Mythic/Localizable.xcstrings index c237705d..617b4d92 100644 --- a/Mythic/Localizable.xcstrings +++ b/Mythic/Localizable.xcstrings @@ -2289,9 +2289,6 @@ } } } - }, - "Change Bottle..." : { - }, "Check for Updates…" : { "localizations" : { @@ -9207,7 +9204,10 @@ } } }, - "q" : { + "raaa %@" : { + + }, + "raaah %@" : { }, "RECENTLY PLAYED" : { @@ -12790,6 +12790,9 @@ } } } + }, + "You probably left this open while installing. Your install has finished." : { + } }, "version" : "1.0" diff --git a/Mythic/Utilities/FileLocations.swift b/Mythic/Utilities/FileLocations.swift index 8e89a230..53b1edf4 100644 --- a/Mythic/Utilities/FileLocations.swift +++ b/Mythic/Utilities/FileLocations.swift @@ -112,19 +112,21 @@ class FileLocations { // MARK: - Other - struct FileDoesNotExistError: Error { + struct FileDoesNotExistError: LocalizedError { init(_ fileURL: URL?) { self.fileURL = fileURL } let fileURL: URL? + var errorDescription: String? = "The file/folder doesn't exist." } - struct FileNotModifiableError: Error { + struct FileNotModifiableError: LocalizedError { init(_ fileURL: URL?) { self.fileURL = fileURL } let fileURL: URL? + var errorDescription: String? = "The file/folder isn't modifiable." } } diff --git a/Mythic/Utilities/Libraries/Extensions/LibrariesExt.swift b/Mythic/Utilities/Libraries/Extensions/LibrariesExt.swift index 1729dc52..5c6de6e7 100644 --- a/Mythic/Utilities/Libraries/Extensions/LibrariesExt.swift +++ b/Mythic/Utilities/Libraries/Extensions/LibrariesExt.swift @@ -18,8 +18,12 @@ import Foundation extension Libraries { /// An error indicating that the libraries are already installed. - struct AlreadyInstalledError: Error { } + struct AlreadyInstalledError: LocalizedError { + var errorDescription: String? = "Mythic Engine is already installed." + } /// An error indicating that the libraries are not installed. - struct NotInstalledError: Error { } + struct NotInstalledError: LocalizedError { + var errorDescription: String? = "Mythic Engine is not installed." + } } diff --git a/Mythic/Views/GameList/GameList.swift b/Mythic/Views/GameList/GameList.swift index dc858698..4a886f69 100644 --- a/Mythic/Views/GameList/GameList.swift +++ b/Mythic/Views/GameList/GameList.swift @@ -302,7 +302,7 @@ struct GameListView: View { ) } } else { - throw NSError() + throw Wine.PrefixDoesNotExistError() } } catch { LaunchError.game = game diff --git a/Mythic/Views/Navigation/Wine.swift b/Mythic/Views/Navigation/Wine.swift index 58618aca..919b6a5c 100644 --- a/Mythic/Views/Navigation/Wine.swift +++ b/Mythic/Views/Navigation/Wine.swift @@ -18,6 +18,15 @@ import SwiftUI struct WineView: View { var body: some View { NotImplementedView() + if let bottles = Wine.allBottles { + List { + ForEach(Array(bottles.keys), id: \.self) { name in + Text("raaa \(name)") + Text("raaah \(bottles[name]!.url.prettyPath())") + } + } + .padding() + } } }