git.iko.soy/distributed-process
on master help sign in
Show error when spawn fails
6ea27d8Edsko de Vries
distributed-process/src/Control/Distributed/Process.hs+4−4
@@ -294,14 +294,14 @@ spawn nid proc = do
294 `seqCP` proc
294 `seqCP` proc
295 mPid <- receiveWait
295 mPid <- receiveWait
296 [ matchIf (\(DidSpawn ref _) -> ref == sRef)
296 [ matchIf (\(DidSpawn ref _) -> ref == sRef)
297− (\(DidSpawn _ pid) -> return $ Just pid)
297+ (\(DidSpawn _ pid) -> return $ Right pid)
298 , matchIf (\(NodeMonitorNotification ref _ _) -> ref == mRef)
298 , matchIf (\(NodeMonitorNotification ref _ _) -> ref == mRef)
299− (\_ -> return Nothing)
299+ (\(NodeMonitorNotification _ _ err) -> return $ Left err)
300 ]
300 ]
301 unmonitor mRef
301 unmonitor mRef
302 case mPid of
302 case mPid of
303− Nothing -> fail "spawn: remote node failed"
303+ Left err -> fail $ "spawn: remote node failed: " ++ show err
304− Just pid -> send pid () >> return pid
304+ Right pid -> send pid () >> return pid
305
305
306-- | Spawn a process and link to it
306-- | Spawn a process and link to it
307--
307--