do { let file = try FileManager.create(…) } catch { logger.error("Failed creating file", metadata: ["error": "\(error)"]) }
You can opt-out of the error handling, but it’s frowned upon, and explicit:
let file = try? FileManager.create(…)
let file = try! FileManager.create(…)
You can opt-out of the error handling, but it’s frowned upon, and explicit:
or The former returning an optional file if there is an error, and the latter crashing in case of an error.