From 4da45e4e6fe36d74d00845d77a00743bc9baf4cf Mon Sep 17 00:00:00 2001 From: Kare Morstol Date: Wed, 1 Jul 2020 23:21:29 +0200 Subject: [PATCH] Readme: update errors example --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dacfbda..c3bd623 100644 --- a/README.md +++ b/README.md @@ -392,12 +392,12 @@ runAsync("cmd1", "arg1").stdout.runAsync("cmd2").stdout.write(to: &file) If the command provided to `runAsync` could not be launched for any reason the program will print the error to standard error and exit, as is usual in scripts. The `runAsync("cmd").finish()` method throws an error if the exit code of the command is anything but 0: ```swift -let command = runAsync("cmd", "-n", 245) +let someCommand = runAsync("cmd", "-n", 245) // ... do { - try command.finish() -} catch CommandError.returnedErrorCode(let error) { - // use error.command or error.errorcode + try someCommand.finish() +} catch let CommandError.returnedErrorCode(command, errorcode) { + print("Command '\(command)' finished with exit code \(errorcode).") } ```