mirror of
https://github.com/passepartoutvpn/wireguard-apple.git
synced 2025-02-17 05:12:02 +00:00
Error handling: alertText() can be nil
Indicating that no alert is to be shown for that error.
This commit is contained in:
parent
d3ba76def3
commit
305264d064
@ -8,7 +8,7 @@ class ErrorPresenter {
|
|||||||
static func showErrorAlert(error: WireGuardAppError, from sourceVC: UIViewController?,
|
static func showErrorAlert(error: WireGuardAppError, from sourceVC: UIViewController?,
|
||||||
onDismissal: (() -> Void)? = nil, onPresented: (() -> Void)? = nil) {
|
onDismissal: (() -> Void)? = nil, onPresented: (() -> Void)? = nil) {
|
||||||
guard let sourceVC = sourceVC else { return }
|
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
|
let okAction = UIAlertAction(title: "OK", style: .default) { (_) in
|
||||||
onDismissal?()
|
onDismissal?()
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ enum TunnelsManagerError: WireGuardAppError {
|
|||||||
case tunnelActivationFailedInternalError // startTunnel() succeeded, but activation failed
|
case tunnelActivationFailedInternalError // startTunnel() succeeded, but activation failed
|
||||||
case tunnelActivationFailedNoInternetConnection // startTunnel() succeeded, but activation failed since no internet
|
case tunnelActivationFailedNoInternetConnection // startTunnel() succeeded, but activation failed since no internet
|
||||||
|
|
||||||
func alertText() -> (String, String) {
|
func alertText() -> (String, String)? {
|
||||||
switch (self) {
|
switch (self) {
|
||||||
case .tunnelNameEmpty:
|
case .tunnelNameEmpty:
|
||||||
return ("No name provided", "Can't create tunnel with an empty name")
|
return ("No name provided", "Can't create tunnel with an empty name")
|
||||||
|
@ -2,5 +2,5 @@
|
|||||||
// Copyright © 2018 WireGuard LLC. All Rights Reserved.
|
// Copyright © 2018 WireGuard LLC. All Rights Reserved.
|
||||||
|
|
||||||
protocol WireGuardAppError: Error {
|
protocol WireGuardAppError: Error {
|
||||||
func alertText() -> (/* title */ String, /* message */ String)
|
func alertText() -> (/* title */ String, /* message */ String)?
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ enum ZipArchiveError: WireGuardAppError {
|
|||||||
case cantOpenOutputZipFileForWriting
|
case cantOpenOutputZipFileForWriting
|
||||||
case badArchive
|
case badArchive
|
||||||
|
|
||||||
func alertText() -> (String, String) {
|
func alertText() -> (String, String)? {
|
||||||
switch (self) {
|
switch (self) {
|
||||||
case .cantOpenInputZipFile:
|
case .cantOpenInputZipFile:
|
||||||
return ("Unable to read zip archive", "The zip archive could not be read.")
|
return ("Unable to read zip archive", "The zip archive could not be read.")
|
||||||
|
@ -6,7 +6,7 @@ import UIKit
|
|||||||
enum ZipExporterError: WireGuardAppError {
|
enum ZipExporterError: WireGuardAppError {
|
||||||
case noTunnelsToExport
|
case noTunnelsToExport
|
||||||
|
|
||||||
func alertText() -> (String, String) {
|
func alertText() -> (String, String)? {
|
||||||
switch (self) {
|
switch (self) {
|
||||||
case .noTunnelsToExport:
|
case .noTunnelsToExport:
|
||||||
return ("Nothing to export", "There are no tunnels to export")
|
return ("Nothing to export", "There are no tunnels to export")
|
||||||
|
@ -6,7 +6,7 @@ import UIKit
|
|||||||
enum ZipImporterError: WireGuardAppError {
|
enum ZipImporterError: WireGuardAppError {
|
||||||
case noTunnelsInZipArchive
|
case noTunnelsInZipArchive
|
||||||
|
|
||||||
func alertText() -> (String, String) {
|
func alertText() -> (String, String)? {
|
||||||
switch (self) {
|
switch (self) {
|
||||||
case .noTunnelsInZipArchive:
|
case .noTunnelsInZipArchive:
|
||||||
return ("No tunnels in zip archive", "No .conf tunnel files were found inside the zip archive.")
|
return ("No tunnels in zip archive", "No .conf tunnel files were found inside the zip archive.")
|
||||||
|
Loading…
Reference in New Issue
Block a user