From: Roopesh Chander Date: Mon, 28 Jan 2019 12:16:12 +0000 (+0530) Subject: Logger: Convert do-catch to try? X-Git-Tag: 0.0.20190207-1~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=acecc70397037006fc236f942b62d424a1f22018;p=thirdparty%2Fwireguard-apple.git Logger: Convert do-catch to try? Signed-off-by: Roopesh Chander --- diff --git a/WireGuard/Shared/Logging/Logger.swift b/WireGuard/Shared/Logging/Logger.swift index 6d38820..23cc719 100644 --- a/WireGuard/Shared/Logging/Logger.swift +++ b/WireGuard/Shared/Logging/Logger.swift @@ -41,12 +41,11 @@ public class Logger { os_log("Unable to determine log destination path. Log will not be saved to file.", log: OSLog.default, type: .error) return } - do { - try Logger.global = Logger(withFilePath: filePath) - } catch { + guard let logger = try? Logger(withFilePath: filePath) else { os_log("Unable to open log file for writing. Log will not be saved to file.", log: OSLog.default, type: .error) return } + Logger.global = logger var appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown version" if let appBuild = Bundle.main.infoDictionary?["CFBundleVersion"] as? String { appVersion += " (\(appBuild))"