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