|
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,9 @@ 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 | + _, _ -> if isJust $ toMaybe r.error |
| 241 | + then BySysError |
| 242 | + else unsafeCrashWith $ "Impossible: `spawnSync` child process neither exited nor was killed." |
241 | 243 | , error: toMaybe r.error
|
242 | 244 | }
|
243 | 245 |
|
@@ -282,7 +284,9 @@ spawnSync' command args buildOpts = (UnsafeCP.spawnSync' command args opts) <#>
|
282 | 284 | , exitStatus: case toMaybe r.status, toMaybe r.signal of
|
283 | 285 | Just c, _ -> Normally c
|
284 | 286 | _, Just s -> BySignal s
|
285 |
| - _, _ -> unsafeCrashWith $ "Impossible: `spawnSync` child process neither exited nor was killed." |
| 287 | + _, _ -> if isJust $ toMaybe r.error |
| 288 | + then BySysError |
| 289 | + else unsafeCrashWith $ "Impossible: `spawnSync` child process neither exited nor was killed." |
286 | 290 | , error: toMaybe r.error
|
287 | 291 | }
|
288 | 292 | where
|
|
0 commit comments