aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2018-10-28 22:57:58 +0530
committerRoopesh Chander <roop@roopc.net>2018-10-28 23:19:56 +0530
commit981a745bcc4eed8c9aa74986e78efa2ade2c152a (patch)
tree403cb371a348d0346c2f11fd68a5a2ffcf27eaa5 /WireGuard
parentQR code: Support some form of rotation. (diff)
downloadwireguard-apple-981a745bcc4eed8c9aa74986e78efa2ade2c152a.tar.xz
wireguard-apple-981a745bcc4eed8c9aa74986e78efa2ade2c152a.zip
QR code: Minor refactoring
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard')
-rw-r--r--WireGuard/WireGuard/UI/iOS/QRScanViewController.swift10
1 files changed, 5 insertions, 5 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/QRScanViewController.swift b/WireGuard/WireGuard/UI/iOS/QRScanViewController.swift
index 60185973..5ae8d089 100644
--- a/WireGuard/WireGuard/UI/iOS/QRScanViewController.swift
+++ b/WireGuard/WireGuard/UI/iOS/QRScanViewController.swift
@@ -96,13 +96,13 @@ class QRScanViewController: UIViewController {
}
func scanDidComplete(withCode code: String) {
- do {
- let tunnelConfiguration = try WgQuickConfigFileParser.parse(code, name: "Scanned")
- delegate?.scannedQRCode(tunnelConfiguration: tunnelConfiguration, qrScanViewController: self)
- dismiss(animated: true, completion: nil)
- } catch {
+ let scannedTunnelConfiguration = try? WgQuickConfigFileParser.parse(code, name: "Scanned")
+ guard let tunnelConfiguration = scannedTunnelConfiguration else {
scanDidEncounterError(title: "Invalid Code", message: "The scanned code is not a valid WireGuard config file.")
+ return
}
+ delegate?.scannedQRCode(tunnelConfiguration: tunnelConfiguration, qrScanViewController: self)
+ dismiss(animated: true, completion: nil)
}
func scanDidEncounterError(title: String, message: String) {