Indicating that no alert is to be shown for that error.
Signed-off-by: Roopesh Chander <roop@roopc.net>
static func showErrorAlert(error: WireGuardAppError, from sourceVC: UIViewController?,
onDismissal: (() -> Void)? = nil, onPresented: (() -> Void)? = nil) {
guard let sourceVC = sourceVC else { return }
- let (title, message) = error.alertText()
+ guard let (title, message) = error.alertText() else { return }
let okAction = UIAlertAction(title: "OK", style: .default) { (_) in
onDismissal?()
}
case tunnelActivationFailedInternalError // startTunnel() succeeded, but activation failed
case tunnelActivationFailedNoInternetConnection // startTunnel() succeeded, but activation failed since no internet
- func alertText() -> (String, String) {
+ func alertText() -> (String, String)? {
switch (self) {
case .tunnelNameEmpty:
return ("No name provided", "Can't create tunnel with an empty name")
// Copyright © 2018 WireGuard LLC. All Rights Reserved.
protocol WireGuardAppError: Error {
- func alertText() -> (/* title */ String, /* message */ String)
+ func alertText() -> (/* title */ String, /* message */ String)?
}
case cantOpenOutputZipFileForWriting
case badArchive
- func alertText() -> (String, String) {
+ func alertText() -> (String, String)? {
switch (self) {
case .cantOpenInputZipFile:
return ("Unable to read zip archive", "The zip archive could not be read.")
enum ZipExporterError: WireGuardAppError {
case noTunnelsToExport
- func alertText() -> (String, String) {
+ func alertText() -> (String, String)? {
switch (self) {
case .noTunnelsToExport:
return ("Nothing to export", "There are no tunnels to export")
enum ZipImporterError: WireGuardAppError {
case noTunnelsInZipArchive
- func alertText() -> (String, String) {
+ func alertText() -> (String, String)? {
switch (self) {
case .noTunnelsInZipArchive:
return ("No tunnels in zip archive", "No .conf tunnel files were found inside the zip archive.")