Skip to content

Instantly share code, notes, and snippets.

@DavidPiper94
Created October 20, 2022 04:19
Show Gist options
  • Save DavidPiper94/d927d93df7ada187d15ade3a9c8c9b32 to your computer and use it in GitHub Desktop.
Save DavidPiper94/d927d93df7ada187d15ade3a9c8c9b32 to your computer and use it in GitHub Desktop.
Example code for article about ArgumentParser - Runtime validation
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