aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/ZipArchive/ZipArchive.swift
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2018-12-06 19:05:46 +0530
committerRoopesh Chander <roop@roopc.net>2018-12-07 12:36:19 +0530
commitdcfa9473e955e372d2c32d7fc682a6fa9ff30bdf (patch)
treedfc481407b9b650076635fbe52e7f9f65dbcdd47 /WireGuard/WireGuard/ZipArchive/ZipArchive.swift
parentError handling: Introduce a WireGuardResult type to handle errors in callbacks across the app (diff)
downloadwireguard-apple-dcfa9473e955e372d2c32d7fc682a6fa9ff30bdf.tar.xz
wireguard-apple-dcfa9473e955e372d2c32d7fc682a6fa9ff30bdf.zip
Error handling: Use WireGuardAppError and WireGuardResult throughout the app
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/WireGuard/ZipArchive/ZipArchive.swift')
-rw-r--r--WireGuard/WireGuard/ZipArchive/ZipArchive.swift13
1 files changed, 12 insertions, 1 deletions
diff --git a/WireGuard/WireGuard/ZipArchive/ZipArchive.swift b/WireGuard/WireGuard/ZipArchive/ZipArchive.swift
index d9078031..2faa5164 100644
--- a/WireGuard/WireGuard/ZipArchive/ZipArchive.swift
+++ b/WireGuard/WireGuard/ZipArchive/ZipArchive.swift
@@ -3,10 +3,21 @@
import Foundation
-enum ZipArchiveError: Error {
+enum ZipArchiveError: WireGuardAppError {
case cantOpenInputZipFile
case cantOpenOutputZipFileForWriting
case badArchive
+
+ func alertText() -> (String, String) {
+ switch (self) {
+ case .cantOpenInputZipFile:
+ return ("Unable to read zip archive", "The zip archive could not be read.")
+ case .cantOpenOutputZipFileForWriting:
+ return ("Unable to create zip archive", "Could not open zip file for writing.")
+ case .badArchive:
+ return ("Unable to read zip archive", "Bad or corrupt zip archive.")
+ }
+ }
}
class ZipArchive {