aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/iOS/QRScanViewController.swift
diff options
context:
space:
mode:
Diffstat (limited to 'WireGuard/WireGuard/UI/iOS/QRScanViewController.swift')
-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 6018597..5ae8d08 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) {