mirror of
https://github.com/XcodesOrg/XcodesApp.git
synced 2026-03-25 08:55:46 +00:00
add error message when trying to uninstall Xcode if file not found
This commit is contained in:
parent
13e829ca88
commit
ed2e5bfcaa
4 changed files with 31 additions and 2 deletions
23
Xcodes/Backend/FileError.swift
Normal file
23
Xcodes/Backend/FileError.swift
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
//
|
||||
// FileError.swift
|
||||
// Xcodes
|
||||
//
|
||||
// Created by Leon Wolf on 06.10.22.
|
||||
// Copyright © 2022 Robots and Pencils. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import LegibleError
|
||||
|
||||
enum FileError: LocalizedError{
|
||||
case fileNotFound(_ fileName: String)
|
||||
}
|
||||
|
||||
extension FileError {
|
||||
var errorDescription: String? {
|
||||
switch self {
|
||||
case .fileNotFound(let fileName):
|
||||
return String(format: localizeString("Alert.Uninstall.Error.Message.FileNotFound"), fileName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,11 @@ extension FileManager {
|
|||
@discardableResult
|
||||
func trashItem(at url: URL) throws -> URL {
|
||||
var resultingItemURL: NSURL!
|
||||
try trashItem(at: url, resultingItemURL: &resultingItemURL)
|
||||
if fileExists(atPath: url.path) {
|
||||
try trashItem(at: url, resultingItemURL: &resultingItemURL)
|
||||
} else {
|
||||
throw FileError.fileNotFound(url.lastPathComponent)
|
||||
}
|
||||
return resultingItemURL as URL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,6 +156,7 @@
|
|||
"Alert.Uninstall.Title" = "Xcode %@ deinstallieren?";
|
||||
"Alert.Uninstall.Message" = "Die Anwendung wird in den Papierkorb verschoben, dieser wird aber nicht geleert.";
|
||||
"Alert.Uninstall.Error.Title" = "Die Deinstallation von Xcode ist nicht möglich";
|
||||
"Alert.Uninstall.Error.Message.FileNotFound" = "Datei \"%@\" konnte nicht gefunden werden.";
|
||||
|
||||
// Cancel Install
|
||||
"Alert.CancelInstall.Title" = "Bist du sicher, dass Du die installation von Xcode %@ anhalten möchtest?";
|
||||
|
|
|
|||
|
|
@ -156,6 +156,7 @@
|
|||
"Alert.Uninstall.Title" = "Uninstall Xcode %@?";
|
||||
"Alert.Uninstall.Message" = "It will be moved to the Trash, but won't be emptied.";
|
||||
"Alert.Uninstall.Error.Title" = "Unable to uninstall Xcode";
|
||||
"Alert.Uninstall.Error.Message.FileNotFound" = "Could not find file \"%@\".";
|
||||
|
||||
// Cancel Install
|
||||
"Alert.CancelInstall.Title" = "Are you sure you want to stop the installation of Xcode %@?";
|
||||
|
|
|
|||
Loading…
Reference in a new issue