Open mitsuyoshi-yamazaki opened 7 years ago
Thanks for your reporting!
I'll consider some solutions for avoiding Obj-C exceptions without using Objective-C code. Because this is a specific Issue on MacOS and If we consider portability with other platforms(such as Linux) the Objective-C code should not be there.
Agenda
When
exetutablePath
is not valid (say "No such file or directory"),Proc.init(exetutablePath: arguments: environment:)
throws NSInvalidArgumentException and crashes.process.launch()
inside ofProc.init(exetutablePath: arguments: environment:)
throws it.How to reproduce
Call
Proc.init(exetutablePath: arguments: environment:)
with invalidexetutablePath
.In my case, Docker was not installed on the local environment and accessing
/usr/local/bin/docker
causes crash.Error log
Recovery suggestion
Process.launch() does NOT throw Swift exceptions but Obj-C exceptions, those we can't handle in Swift codes. There's a way to convert Obj-c exceptions to Swift exceptions like this but it needs Obj-C implementation, I don't know it's possible to build Obj-C code with
$ swift build