Created
October 20, 2022 04:19
-
-
Save DavidPiper94/d927d93df7ada187d15ade3a9c8c9b32 to your computer and use it in GitHub Desktop.
Example code for article about ArgumentParser - Runtime validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mutating func run() throws { | |
let filePathWithExtension = "\(filePath)\(fileExtension)" | |
// 1 | |
do { | |
try note.write(toFile: filePathWithExtension, atomically: true, encoding: .utf8) | |
} catch { | |
// 2 | |
throw RuntimeError("Couldn't write to `\(filePath)`!") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment