git.iko.soy/distributed-process
on master help sign in
Added ProcessId to ProcessKillException, changed catchExit signature, and changed ProcessExitException show
commitcdedc037c3ef194aa7ca83b89b0fc73abd3092db authorRodLogic <dev@rodlogic.net> dateMon 3 Dec 2012, 12:01 (14 years ago) parentd31ba89
2 files changed+9−9
distributed-process/src/Control/Distributed/Process/Internal/Primitives.hs+7−7 distributed-process/src/Control/Distributed/Process/Node.hs+2−2
distributed-process/src/Control/Distributed/Process/Internal/Primitives.hs+7−7
@@ -344,13 +344,13 @@ kill them reason = do
344344 else sendCtrlMsg (Just nid) (Kill them reason)
345345
346346-- | Thrown by 'kill'
347−newtype ProcessKillException =
348− ProcessKillException String
347+data ProcessKillException =
348+ ProcessKillException !ProcessId !String
349349 deriving (Typeable)
350350
351351instance Exception ProcessKillException
352352instance Show ProcessKillException where
353− show (ProcessKillException reason) = reason
353+ show (ProcessKillException pid reason) = "Kill by " ++ show pid ++ " : " ++ reason
354354
355355
356356-- | Graceful request to exit a process
@@ -372,18 +372,18 @@ data ProcessExitException =
372372
373373instance Exception ProcessExitException
374374instance Show ProcessExitException where
375− show (ProcessExitException _ reason) = show reason
375+ show (ProcessExitException pid _) = "Exit by " ++ show pid
376376
377377-- | Catches ProcessExitException
378−catchExit :: forall a b . (Show a, Serializable a) => Process b -> (ProcessId -> a -> Process ()) -> Process b
378+catchExit :: forall a b . (Show a, Serializable a) => Process b -> (ProcessId -> a -> Process b) -> Process b
379379catchExit act exitHandler = catch act handleExit
380380 where
381381 handleExit ex@(ProcessExitException from msg) =
382382 if messageFingerprint msg == fingerprint (undefined :: a)
383383 then do
384384 let reason = decoded
385− exitHandler from reason
386− liftIO . throwIO $ ProcessKillException (show reason)
385+ _ <- exitHandler from reason
386+ liftIO $ throwIO ex
387387 else liftIO $ throwIO ex
388388 where
389389 decoded :: a
distributed-process/src/Control/Distributed/Process/Node.hs+2−2
@@ -725,8 +725,8 @@ ncEffectNamedSend from label msg = do
725725
726726-- [Issue #69]
727727ncEffectKill :: ProcessId -> ProcessId -> String -> NC ()
728−ncEffectKill _ to reason =
729− throwException to $ ProcessKillException reason
728+ncEffectKill from to reason =
729+ throwException to $ ProcessKillException from reason
730730
731731-- [Issue #69]
732732ncEffectExit :: ProcessId -> ProcessId -> Message -> NC ()