|
21 | 21 | -- | defined in this library that doesn't exist in the Node docs. |
22 | 22 | -- | It exists to allow the end-user to append additional values to the `safeStdio` value |
23 | 23 | -- | used here. For example, |
24 | | --- | |
| 24 | +-- | |
25 | 25 | -- | ``` |
26 | 26 | -- | spawn' file args (_ { appendStdio = Just [ fileDescriptor8, pipe, pipe ]}) |
27 | 27 | -- | ``` |
@@ -86,7 +86,7 @@ module Node.ChildProcess |
86 | 86 |
|
87 | 87 | import Prelude |
88 | 88 |
|
89 | | -import Data.Maybe (Maybe(..), fromMaybe) |
| 89 | +import Data.Maybe (Maybe(..), fromMaybe, isJust) |
90 | 90 | import Data.Nullable (Nullable, toMaybe, toNullable) |
91 | 91 | import Data.Posix (Pid, Gid, Uid) |
92 | 92 | import Data.Posix.Signal (Signal) |
@@ -237,7 +237,11 @@ spawnSync command args = (UnsafeCP.spawnSync command args) <#> \r -> |
237 | 237 | , exitStatus: case toMaybe r.status, toMaybe r.signal of |
238 | 238 | Just c, _ -> Normally c |
239 | 239 | _, Just s -> BySignal s |
240 | | - _, _ -> unsafeCrashWith $ "Impossible: `spawnSync` child process neither exited nor was killed." |
| 240 | + _, _ -> |
| 241 | + if isJust $ toMaybe r.error then |
| 242 | + BySysError |
| 243 | + else |
| 244 | + unsafeCrashWith $ "Impossible: `spawnSync` child process neither exited nor was killed." |
241 | 245 | , error: toMaybe r.error |
242 | 246 | } |
243 | 247 |
|
@@ -282,7 +286,11 @@ spawnSync' command args buildOpts = (UnsafeCP.spawnSync' command args opts) <#> |
282 | 286 | , exitStatus: case toMaybe r.status, toMaybe r.signal of |
283 | 287 | Just c, _ -> Normally c |
284 | 288 | _, Just s -> BySignal s |
285 | | - _, _ -> unsafeCrashWith $ "Impossible: `spawnSync` child process neither exited nor was killed." |
| 289 | + _, _ -> |
| 290 | + if isJust $ toMaybe r.error then |
| 291 | + BySysError |
| 292 | + else |
| 293 | + unsafeCrashWith $ "Impossible: `spawnSync` child process neither exited nor was killed." |
286 | 294 | , error: toMaybe r.error |
287 | 295 | } |
288 | 296 | where |
|
0 commit comments